Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: -fstrict-overflow and -Wstrict-overflow
(2012/10/13 3:13), Alan Barrett wrote:
> On Fri, 12 Oct 2012, Masanobu SAITOH wrote:
>> One of (serious) problem that we can't use -Wstrict-overflow by default
>> is that gcc sometimes misundestand it :-<
>>
>> How should we use it?
>
> Do you have an example where gcc does the wrong thing with -Wstrict-overflow?
> (The example in your message, which I am not quoting here, showed gcc doing
> the right thing: that is, drawing attention to a case where the program
> invoked undefined behaviour.)
One of example is src/lib/libm/src/e_jn.c
> five(msaitoh)% env USETOOLS=no make e_jn.o
> # compile libm/e_jn.o
> gcc -O2 -Wstrict-overflow -std=gnu99 -Wall -Wstrict-prototypes
> -Wmissing-prototypes -Wpointer-arith -Wno-sign-compare -Wno-traditional
> -Wa,--fatal-warnings -Wreturn-type -Wswitch -Wshadow -Wcast-qual
> -Wwrite-strings -Wextra -Wno-unused-parameter -Wno-sign-compare
> -Wold-style-definition -Wsign-compare -Wformat=2 -Wno-format-zero-length
> -Werror -fno-strict-aliasing -D_MULTI_LIBM -D_POSIX_MODE -DLIBM_SCCS
> -I/disk/sources/4NetBSD-current/src/lib/libm/gen -c
> /disk/sources/4NetBSD-current/src/lib/libm/src/e_jn.c -o e_jn.o
> cc1: warnings being treated as errors
> /disk/sources/4NetBSD-current/src/lib/libm/src/e_jn.c: In function
> '__ieee754_jn':
> /disk/sources/4NetBSD-current/src/lib/libm/src/e_jn.c:75:4: error: assuming
> signed overflow does not occur when simplifying conditional to constant
> /disk/sources/4NetBSD-current/src/lib/libm/src/e_jn.c:107:10: error: assuming
> signed overflow does not occur when simplifying conditional to constant
> /disk/sources/4NetBSD-current/src/lib/libm/src/e_jn.c:184:11: error: assuming
> signed overflow does not occur when simplifying conditional to constant
> /disk/sources/4NetBSD-current/src/lib/libm/src/e_jn.c:192:11: error: assuming
> signed overflow does not occur when simplifying conditional to constant
> /disk/sources/4NetBSD-current/src/lib/libm/src/e_jn.c: In function
> '__ieee754_yn':
> /disk/sources/4NetBSD-current/src/lib/libm/src/e_jn.c:236:4: error: assuming
> signed overflow does not occur when simplifying conditional to constant
> /disk/sources/4NetBSD-current/src/lib/libm/src/e_jn.c:266:6: error: assuming
> signed overflow does not occur when simplifying conditional to constant
> *** Error code 1
>
> Stop.
I have not confident that e_jn.c has no bug though...
> --apb (Alan Barrett)
--
-----------------------------------------------
SAITOH Masanobu (msaitoh%execsw.org@localhost
msaitoh%netbsd.org@localhost)
Home |
Main Index |
Thread Index |
Old Index