This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: BUG: assuming signed overflow does not occur when simplifying conditional to constant
- From: Bruce Korb <bruce dot korb at gmail dot com>
- To: GCC <gcc at gcc dot gnu dot org>
- Date: Sat, 29 Dec 2012 12:21:09 -0800
- Subject: Re: BUG: assuming signed overflow does not occur when simplifying conditional to constant
- References: <50DF505E.70402@gmail.com>
(Tarball attachment (75K) stripped.)
On 12/29/12 10:56, Florian Weimer wrote:
>> Not easily. git clone git://git.savannah.gnu.org/autogen.git
>
> Uhm, I get:
>
> configure.ac:30: error: AC_INIT should be called with package and version arguments
I ought to have directed you to a pre-release tarball. Sorry.
The GIT source needs to be bootstrapped.
> libtool: compile: gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I../../autoopts \
> -I.. -I.. -I../.. -I../autoopts -I../../autoopts \
> -DPKGDATADIR=\"/u/bkorb/ag/ag/autogen-5.17.1pre3/_inst/share/autogen\" \
> -g -O2 -Wall -Werror -Wcast-align -Wmissing-prototypes -Wpointer-arith \
> -Wshadow -Wstrict-prototypes -Wwrite-strings -Wno-format-contains-nul \
> -fno-strict-aliasing -Wstrict-aliasing=2 -Wextra -Wconversion \
> -Wsign-conversion -Wstrict-overflow -MT libopts_la-libopts.lo \
> -MD -MP -MF .deps/libopts_la-libopts.Tpo \
> -c libopts.c -fPIC -DPIC \
> -o .libs/libopts_la-libopts.o
> In file included from libopts.c:22:0:
> ../../autoopts/configfile.c: In function 'intern_file_load':
> ../../autoopts/configfile.c:1025:12: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
> cc1: all warnings being treated as errors
> make[4]: *** [libopts_la-libopts.lo] Error 1
> make[4]: Leaving directory `/u/bkorb/ag/ag/autogen-5.17.1pre3/_build/autoopts'
> make[3]: *** [all-recursive] Error 1
> make[3]: Leaving directory `/u/bkorb/ag/ag/autogen-5.17.1pre3/_build/autoopts'
>> I'd have to prune code until I can't prune more.
>
> Preprocessed sources would be helpful.
Interesting. Capturing the above command line, preprocessing and then
compiling yields different messages:
> libopts.i: In function 'gnu_dev_major':
> libopts.i:137:3: error: negative integer implicitly converted to unsigned type [-Werror=sign-conversion]
> libopts.i:137:33: error: conversion to 'unsigned int' from 'long long unsigned int' may alter its value [-Werror=conversion]
> libopts.i: In function 'gnu_dev_minor':
> libopts.i:142:3: error: negative integer implicitly converted to unsigned type [-Werror=sign-conversion]
> libopts.i:142:25: error: conversion to 'unsigned int' from 'long long unsigned int' may alter its value [-Werror=conversion]
> libopts.i: In function 'gnu_dev_makedev':
> libopts.i:148:4: error: negative integer implicitly converted to unsigned type [-Werror=sign-conversion]
> libopts.i:149:4: error: negative integer implicitly converted to unsigned type [-Werror=sign-conversion]
> libopts.i: In function '__sigismember':
> libopts.i:424:174: error: conversion to 'long unsigned int' from 'int' may change the sign of the result [-Werror=sign-conversion]
> libopts.i:424:254: error: conversion to 'long unsigned int' from 'int' may change the sign of the result [-Werror=sign-conversion]
> libopts.i: In function '__sigaddset':
> libopts.i:425:165: error: conversion to 'long unsigned int' from 'int' may change the sign of the result [-Werror=sign-conversion]
> libopts.i:425:245: error: conversion to 'long unsigned int' from 'int' may change the sign of the result [-Werror=sign-conversion]
> libopts.i: In function '__sigdelset':
> libopts.i:426:165: error: conversion to 'long unsigned int' from 'int' may change the sign of the result [-Werror=sign-conversion]
> libopts.i:426:245: error: conversion to 'long unsigned int' from 'int' may change the sign of the result [-Werror=sign-conversion]
> libopts.i: In function 'fputc_unlocked':
> libopts.i:1253:3: error: conversion to 'char' from 'int' may alter its value [-Werror=conversion]
> libopts.i: In function 'putc_unlocked':
> libopts.i:1258:3: error: conversion to 'char' from 'int' may alter its value [-Werror=conversion]
> libopts.i: In function 'putchar_unlocked':
> libopts.i:1263:3: error: conversion to 'char' from 'int' may alter its value [-Werror=conversion]
> cc1: all warnings being treated as error
I stripped away the line information. Ah. Of course. GCC no longer knows what is
derived from system headers. :) configfile.c:1025 maps to libopts.i:5416 and
the compiler doesn't get that far.
$ gcc --version
gcc (SUSE Linux) 4.7.1 20120723 [gcc-4_7-branch revision 189773]
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Some of this pre-processed code gets pretty bizarre:
> if ( ((__extension__ (__builtin_constant_p (len) && ((__builtin_constant_p (txt+1) && strlen (txt+1) < ((size_t) (len))) || (__builtin_constant_p (opts->pzPROGNAME) && strlen (opts->pzPROGNAME) < ((size_t) (len)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (txt+1) && __builtin_constant_p (opts->pzPROGNAME) && (__s1_len = strlen (txt+1), __s2_len = strlen (opts->pzPROGNAME), (!((size_t)(const void *)((txt+1) + 1) - (size_t)(const void *)(txt+1) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((opts->pzPROGNAME) + 1) - (size_t)(const void *)(opts->pzPROGNAME) == 1) || __s2_len >= 4)) ? __builtin_strcmp (txt+1, opts->pzPROGNAME) : (__builtin_constant_p (txt+1) && ((size_t)(const void *)((txt+1) + 1) - (size_t)(const void *)(txt+1) == 1) && (__s1_len = strlen (txt+1), __s1_len < 4) ? (__builtin_constant_p (opts->pzPROGNAME) && ((size_t)(const void *)((opts->pzPROGNAME) + 1) - (size_t)(const void *)(opts->pzPROGNAME) == 1) ? __builtin_strcmp (txt+1, opts->pz
PROGNAME) : (__extension__ ({ __const unsigned char *__s2 = (__const unsigned char *) (__const char *) (opts->pzPROGNAME); register int __result = (((__const unsigned char *) (__const char *) (txt+1))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((__const unsigned char *) (__const char *) (txt+1))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((__const unsigned char *) (__const char *) (txt+1))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((__const unsigned char *) (__const char *) (txt+1))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (opts->pzPROGNAME) && ((size_t)(const void *)((opts->pzPROGNAME) + 1) - (size_t)(const void *)(opts->pzPROGNAME) == 1) && (__s2_len = strlen (opts->pzPROGNAME), __s2_len < 4) ? (__builtin_constant_p (txt+1) && ((size_t)(const void *)((txt+1) + 1) - (size_t)(const void *)(txt+1) == 1) ? __builtin_strcmp (txt+1, opts->pzPROGNAME) : (__extension__ ({ __const unsigned char *__s1 = (__const un
signed char *) (__const char *) (txt+1); register int __result = __s1[0] - ((__const unsigned char *) (__const char *) (opts->pzPROGNAME))[0]; if (__s2_len > 0 && __result == 0) { __result = (__s1[1] - ((__const unsigned char *) (__const char *) (opts->pzPROGNAME))[1]); if (__s2_len > 1 && __result == 0) { __result = (__s1[2] - ((__const unsigned char *) (__const char *) (opts->pzPROGNAME))[2]); if (__s2_len > 2 && __result == 0) __result = (__s1[3] - ((__const unsigned char *) (__const char *) (opts->pzPROGNAME))[3]); } } __result; }))) : __builtin_strcmp (txt+1, opts->pzPROGNAME)))); }) : strncmp (txt+1, opts->pzPROGNAME, len))) == 0)
Anyway, I tried trimming stuff to get back to the original message, but to no avail.
Attached is a tarball of the pre-processed text with and without blank lines
and #line directives.
Thank you again. Regards, Bruce