Bug 54528 - [4.8 Regression] system.h:288:78: error: integer overflow in expression
Summary: [4.8 Regression] system.h:288:78: error: integer overflow in expression
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: preprocessor (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: 4.8.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-08 15:41 UTC by John David Anglin
Modified: 2012-09-27 11:45 UTC (History)
3 users (show)

See Also:
Host: hppa*-*-* (32-bit)
Target: hppa*-*-* (32-bit)
Build: hppa*-*-* (32-bit)
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Preprocessed source (57.88 KB, text/plain)
2012-09-08 15:41 UTC, John David Anglin
Details
Patch that "fixes" the problem (325 bytes, patch)
2012-09-12 15:48 UTC, Mark Kettenis
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John David Anglin 2012-09-08 15:41:22 UTC
Created attachment 28153 [details]
Preprocessed source

/home/dave/gnu/gcc/objdir/./prev-gcc/g++ -B/home/dave/gnu/gcc/objdir/./prev-gcc/
 -B/home/dave/opt/gnu/gcc/gcc-4.8.0/hppa-linux-gnu/bin/ -nostdinc++ -B/home/dave
/gnu/gcc/objdir/prev-hppa-linux-gnu/libstdc++-v3/src/.libs -B/home/dave/gnu/gcc/
objdir/prev-hppa-linux-gnu/libstdc++-v3/libsupc++/.libs -I/home/dave/gnu/gcc/obj
dir/prev-hppa-linux-gnu/libstdc++-v3/include/hppa-linux-gnu -I/home/dave/gnu/gcc
/objdir/prev-hppa-linux-gnu/libstdc++-v3/include -I/home/dave/gnu/gcc/gcc/libstdc++-v3/libsupc++ -L/home/dave/gnu/gcc/objdir/prev-hppa-linux-gnu/libstdc++-v3/sr
c/.libs -L/home/dave/gnu/gcc/objdir/prev-hppa-linux-gnu/libstdc++-v3/libsupc++/.
libs -c   -g -O2 -DIN_GCC   -fno-exceptions -fno-rtti -W -Wall -Wno-narrowing -W
write-strings -Wcast-qual -Wmissing-format-attribute -pedantic -Wno-long-long -W
no-variadic-macros -Wno-overlength-strings -Werror -fno-common  -DHAVE_CONFIG_H 
-I. -I. -I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include -I../../gcc
/gcc/../libcpp/include  -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libde
cnumber/dpd -I../libdecnumber    ../../gcc/gcc/mcf.c -o mcf.o
In file included from ../../gcc/gcc/mcf.c:47:0:
../../gcc/gcc/mcf.c: In function ‘void dump_fixup_edge(FILE*, fixup_graph_type*, fixup_edge_p)’:
../../gcc/gcc/system.h:288:78: error: integer overflow in expression [-Werror=overflow]
                              ? ~ (t) 0 << (sizeof(t) * CHAR_BIT - 1) : (t) 0))
                                                                              ^
../../gcc/gcc/system.h:289:44: note: in expansion of macro 'INTTYPE_MINIMUM'
 #define INTTYPE_MAXIMUM(t) ((t) (~ (t) 0 - INTTYPE_MINIMUM (t)))
                                            ^
../../gcc/gcc/mcf.c:55:22: note: in expansion of macro 'INTTYPE_MAXIMUM'
 #define CAP_INFINITY INTTYPE_MAXIMUM (HOST_WIDEST_INT)
                      ^
../../gcc/gcc/mcf.c:211:34: note: in expansion of macro 'CAP_INFINITY'
       if (fedge->max_capacity == CAP_INFINITY)
                                  ^
../../gcc/gcc/system.h:288:78: error: integer overflow in expression [-Werror=overflow]
                              ? ~ (t) 0 << (sizeof(t) * CHAR_BIT - 1) : (t) 0))
                                                                              ^
../../gcc/gcc/system.h:289:44: note: in expansion of macro 'INTTYPE_MINIMUM'
 #define INTTYPE_MAXIMUM(t) ((t) (~ (t) 0 - INTTYPE_MINIMUM (t)))
                                            ^
../../gcc/gcc/mcf.c:55:22: note: in expansion of macro 'INTTYPE_MAXIMUM'
 #define CAP_INFINITY INTTYPE_MAXIMUM (HOST_WIDEST_INT)
                      ^
../../gcc/gcc/mcf.c:219:27: note: in expansion of macro 'CAP_INFINITY'
       if (fedge->rflow == CAP_INFINITY)
                           ^
../../gcc/gcc/mcf.c: In function ‘void create_fixup_graph(fixup_graph_type*)’:
../../gcc/gcc/system.h:288:78: error: integer overflow in expression [-Werror=overflow]
                              ? ~ (t) 0 << (sizeof(t) * CHAR_BIT - 1) : (t) 0))
                                                                              ^
../../gcc/gcc/system.h:289:44: note: in expansion of macro 'INTTYPE_MINIMUM'
 #define INTTYPE_MAXIMUM(t) ((t) (~ (t) 0 - INTTYPE_MINIMUM (t)))
                                            ^
../../gcc/gcc/mcf.c:55:22: note: in expansion of macro 'INTTYPE_MAXIMUM'
 #define CAP_INFINITY INTTYPE_MAXIMUM (HOST_WIDEST_INT)
                      ^
../../gcc/gcc/mcf.c:531:28: note: in expansion of macro 'CAP_INFINITY'
                     fcost, CAP_INFINITY);
                            ^
../../gcc/gcc/system.h:288:78: error: integer overflow in expression [-Werror=overflow]
                              ? ~ (t) 0 << (sizeof(t) * CHAR_BIT - 1) : (t) 0))
                                                                              ^
../../gcc/gcc/system.h:289:44: note: in expansion of macro 'INTTYPE_MINIMUM'
 #define INTTYPE_MAXIMUM(t) ((t) (~ (t) 0 - INTTYPE_MINIMUM (t)))
                                            ^
../../gcc/gcc/mcf.c:55:22: note: in expansion of macro 'INTTYPE_MAXIMUM'
 #define CAP_INFINITY INTTYPE_MAXIMUM (HOST_WIDEST_INT)
                      ^
../../gcc/gcc/mcf.c:543:23: note: in expansion of macro 'CAP_INFINITY'
                       CAP_INFINITY);
                       ^
../../gcc/gcc/mcf.c: In function ‘bool cancel_negative_cycle(fixup_graph_type*, int*, gcov_type*, int*)’:
../../gcc/gcc/system.h:288:78: error: integer overflow in expression [-Werror=overflow]
                              ? ~ (t) 0 << (sizeof(t) * CHAR_BIT - 1) : (t) 0))
                                                                              ^
../../gcc/gcc/system.h:289:44: note: in expansion of macro 'INTTYPE_MINIMUM'
 #define INTTYPE_MAXIMUM(t) ((t) (~ (t) 0 - INTTYPE_MINIMUM (t)))
                                            ^
../../gcc/gcc/mcf.c:55:22: note: in expansion of macro 'INTTYPE_MAXIMUM'
 #define CAP_INFINITY INTTYPE_MAXIMUM (HOST_WIDEST_INT)
                      ^
../../gcc/gcc/mcf.c:806:14: note: in expansion of macro 'CAP_INFINITY'
       d[i] = CAP_INFINITY;
              ^
../../gcc/gcc/system.h:288:78: error: integer overflow in expression [-Werror=overflow]
                              ? ~ (t) 0 << (sizeof(t) * CHAR_BIT - 1) : (t) 0))
                                                                              ^
../../gcc/gcc/system.h:289:44: note: in expansion of macro 'INTTYPE_MINIMUM'
 #define INTTYPE_MAXIMUM(t) ((t) (~ (t) 0 - INTTYPE_MINIMUM (t)))
                                            ^
../../gcc/gcc/mcf.c:55:22: note: in expansion of macro 'INTTYPE_MAXIMUM'
 #define CAP_INFINITY INTTYPE_MAXIMUM (HOST_WIDEST_INT)
                      ^
../../gcc/gcc/mcf.c:822:34: note: in expansion of macro 'CAP_INFINITY'
             && d[pfedge->src] != CAP_INFINITY
                                  ^
../../gcc/gcc/system.h:288:78: error: integer overflow in expression [-Werror=overflow]
                              ? ~ (t) 0 << (sizeof(t) * CHAR_BIT - 1) : (t) 0))
                                                                              ^
../../gcc/gcc/system.h:289:44: note: in expansion of macro 'INTTYPE_MINIMUM'
 #define INTTYPE_MAXIMUM(t) ((t) (~ (t) 0 - INTTYPE_MINIMUM (t)))
                                            ^
../../gcc/gcc/mcf.c:55:22: note: in expansion of macro 'INTTYPE_MAXIMUM'
 #define CAP_INFINITY INTTYPE_MAXIMUM (HOST_WIDEST_INT)
                      ^
../../gcc/gcc/mcf.c:845:32: note: in expansion of macro 'CAP_INFINITY'
           && d[pfedge->src] != CAP_INFINITY
                                ^
../../gcc/gcc/system.h:288:78: error: integer overflow in expression [-Werror=overflow]
                              ? ~ (t) 0 << (sizeof(t) * CHAR_BIT - 1) : (t) 0))
                                                                              ^
../../gcc/gcc/system.h:289:44: note: in expansion of macro 'INTTYPE_MINIMUM'
 #define INTTYPE_MAXIMUM(t) ((t) (~ (t) 0 - INTTYPE_MINIMUM (t)))
                                            ^
../../gcc/gcc/mcf.c:55:22: note: in expansion of macro 'INTTYPE_MAXIMUM'
 #define CAP_INFINITY INTTYPE_MAXIMUM (HOST_WIDEST_INT)
                      ^
../../gcc/gcc/mcf.c:886:16: note: in expansion of macro 'CAP_INFINITY'
   cycle_flow = CAP_INFINITY;
                ^
../../gcc/gcc/mcf.c: In function ‘gcov_type find_max_flow(fixup_graph_type*, int, int)’:
../../gcc/gcc/system.h:288:78: error: integer overflow in expression [-Werror=overflow]
                              ? ~ (t) 0 << (sizeof(t) * CHAR_BIT - 1) : (t) 0))
                                                                              ^
../../gcc/gcc/system.h:289:44: note: in expansion of macro 'INTTYPE_MINIMUM'
 #define INTTYPE_MAXIMUM(t) ((t) (~ (t) 0 - INTTYPE_MINIMUM (t)))
                                            ^
../../gcc/gcc/mcf.c:55:22: note: in expansion of macro 'INTTYPE_MAXIMUM'
 #define CAP_INFINITY INTTYPE_MAXIMUM (HOST_WIDEST_INT)
                      ^
../../gcc/gcc/mcf.c:1056:29: note: in expansion of macro 'CAP_INFINITY'
       gcov_type increment = CAP_INFINITY;
                             ^
cc1plus: all warnings being treated as errors
make[3]: *** [mcf.o] Error 1

dave@mx3210:~/gnu/gcc/objdir/prev-gcc$ ./xgcc -B./ -v
Reading specs from ./specs
COLLECT_GCC=./xgcc
COLLECT_LTO_WRAPPER=./lto-wrapper
Target: hppa-linux-gnu
Configured with: ../gcc/configure --with-gnu-as --with-gnu-ld --enable-shared --enable-multiarch --with-multiarch-defaults=hppa-linux-gnu --enable-linker-build-id --build=hppa-linux-gnu --host=hppa-linux-gnu --target=hppa-linux-gnu --prefix=/home/dave/opt/gnu/gcc/gcc-4.8.0 --with-local-prefix=/home/dave/opt/gnu --enable-threads=posix --enable-__cxa_atexit --build=hppa-linux-gnu --enable-clocale=gnu --enable-java-gc=boehm --without-cloog --without-ppl --enable-languages=c,c++,objc,fortran,obj-c++,java,ada,lto
Thread model: posix
gcc version 4.8.0 20120908 (experimental) [trunk revision 191088] (GCC)
Comment 1 John David Anglin 2012-09-08 20:49:37 UTC
Introduced in revision 191047 (change to new double_int interface).
Comment 2 Mikael Pettersson 2012-09-11 07:21:57 UTC
I got these errors too, when trying to bootstrap gcc-4.8-20120909 on m68k-linux using g++ 4.5.3 as the bootstrap compiler.
Comment 3 Mark Kettenis 2012-09-12 15:48:34 UTC
Created attachment 28177 [details]
Patch that "fixes" the problem
Comment 4 John David Anglin 2012-09-13 00:44:15 UTC
(In reply to comment #3)
> Created attachment 28177 [details]
> Patch that "fixes" the problem

Works for me. I believe the problem is the overflow detection
in the new code.
Comment 5 Mikael Pettersson 2012-09-27 07:06:51 UTC
The bug is still present in gcc-4.8-20120923.
Comment 6 John David Anglin 2012-09-27 11:45:49 UTC
Based on my testing, this was fixed by Lawrence's commit on
the 24th.  It added double_int::sub_with_overflow and
double_int::neg_with_overflow to fix the problem.