develooper Front page | perl.perl5.porters | Postings from February 2003

Re: How about gcc -funsigned-char [Was: Re: one signedness nit for Encode]

Jarkko Hietaniemi
February 16, 2003 20:58
Re: How about gcc -funsigned-char [Was: Re: one signedness nit for Encode]
Message ID:
> >>>-    U8 *trm = term ? SvPV(term, trmlen) : NULL;
> >>>+    U8 *trm = term ? (U8*) SvPV(term, trmlen) : NULL;
> >>
> >>Kiitos.  Typecast and applied.
> >
> >It's a pity gcc doesn't warn about such problems without -pedantic.
> >AIX and Tru64 compilers warn; VMS compilers find it a fatal error.
> GCC does have -funsigned-char, however.

The -funsigned-char is not the same as warning about signed vs
unsigned mismatches.  -funsigned-char just brute-forcedly makes all
chars unsigned, kind of like a global implicit (cast).

The good thing is that very rarely (well, at least in my experience)
does one really want chars to be signed, unsigned is much more useful
and less error-prone (the Perl source for example had until quite
recently a bug where an array was indexed by a char-- bad idea as the
char could get negative).

The bad things are, firstly, well, it's not the same thing as warning
about mismatches.  Secondly, by its "global-casting" nature it's just
a "global-sweeping-under-the-rug" option (how does that work with
system headers and headers of random libraries Perl is compiled
with?).  Thirdly, it works only for chars-- though admittedly, chars
(or char pointers) are the most common cause for such signedness

P.S.  Looking at the gcc man page, I think -malign-loops is an absolutely
delightfully named option.  Can I get -sinister-jumps, too?

Jarkko Hietaniemi <> "There is this special
biologist word we use for 'stable'.  It is 'dead'." -- Jack Cohen Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About