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

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

From:
Jarkko Hietaniemi
Date:
February 16, 2003 20:58
Subject:
Re: How about gcc -funsigned-char [Was: Re: one signedness nit for Encode]
Message ID:
20030217045806.GA22431@kosh.hut.fi
> >>>-    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
mismatches.

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 <jhi@iki.fi> http://www.iki.fi/jhi/ "There is this special
biologist word we use for 'stable'.  It is 'dead'." -- Jack Cohen



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About