http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59231 Bug ID: 59231 Summary: gcc misses [-Werror=sign-compare] when inside a template Product: gcc Version: 4.8.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: a_mcgurn at yahoo dot co.uk The following code: ----------- //filename #include template bool equals( X x, Y y ) { return (x == y); } int main() { std::cout << "Hello World!" << std::endl; size_t x = 2; signed int y = 2; if(!equals( x, y )) { std::cout << "Hello World again - x == y !" << std::endl; } return 0; } ----------- This produces for g++-4.8.2: bfs-dl360g7-27$ g++ --std=c++11 -Wall helloWorld.cpp -o helloWorld NO warnings for g++-4.4.7 it correctly warns on the 'signed == unsigned long' as incorrect: bfs-dl360g7-27$ /usr/bin/g++ -Wall helloWorld.cpp -o helloWorld helloWorld.cpp: In function âbool equals(X, Y) [with X = long unsigned int, Y = int]â: helloWorld.cpp:16: instantiated from here helloWorld.cpp:7: warning: comparison between signed and unsigned integer expressions ---- However if comparison is not inside a template say direct comparison: if(x == y) then g++-4.8.2 will pick this up as a warning: bfs-dl360g7-27$ g++ --std=c++11 -Wall -Werror testComparison.cpp -o testComparison testComparison.cpp: In function âint main()â: testComparison.cpp:9:12: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare] if(x == y) so it appears to have difficulty seeing this issue if wrapped in a template/macro. bfs-dl360g7-27$ g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/gcc-4.8.2/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.8.2/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ./configure --prefix=/opt/gcc-4.8.2 --enable-languages=c,c++ --with-mpc=/opt/gcc-4.8.2 --with-mpfr=/opt/gcc-4.8.2 --with-gmp=/opt/gcc-.8.2 --with-cloog=/opt/gcc-4.8.2 --with-isl=/opt/gcc-4.8.2 Thread model: posix gcc version 4.8.2 (GCC) preprocessed file attached - apologies if i've missed anything vital or a bug already raised. rgds >From gcc-bugs-return-435370-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Nov 21 12:44:45 2013 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 10515 invoked by alias); 21 Nov 2013 12:44:45 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 10022 invoked by uid 48); 21 Nov 2013 12:43:50 -0000 From: "a_mcgurn at yahoo dot co.uk" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/59232] New: gcc misses [-Werror=sign-compare] when inside a template Date: Thu, 21 Nov 2013 12:44:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.8.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: a_mcgurn at yahoo dot co.uk X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-11/txt/msg02147.txt.bz2 Content-length: 2385 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59232 Bug ID: 59232 Summary: gcc misses [-Werror=sign-compare] when inside a template Product: gcc Version: 4.8.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: a_mcgurn at yahoo dot co.uk The following code: ----------- //filename #include template bool equals( X x, Y y ) { return (x == y); } int main() { std::cout << "Hello World!" << std::endl; size_t x = 2; signed int y = 2; if(!equals( x, y )) { std::cout << "Hello World again - x == y !" << std::endl; } return 0; } ----------- This produces for g++-4.8.2: bfs-dl360g7-27$ g++ --std=c++11 -Wall helloWorld.cpp -o helloWorld NO warnings for g++-4.4.7 it correctly warns on the 'signed == unsigned long' as incorrect: bfs-dl360g7-27$ /usr/bin/g++ -Wall helloWorld.cpp -o helloWorld helloWorld.cpp: In function âbool equals(X, Y) [with X = long unsigned int, Y = int]â: helloWorld.cpp:16: instantiated from here helloWorld.cpp:7: warning: comparison between signed and unsigned integer expressions ---- However if comparison is not inside a template say direct comparison: if(x == y) then g++-4.8.2 will pick this up as a warning: bfs-dl360g7-27$ g++ --std=c++11 -Wall -Werror testComparison.cpp -o testComparison testComparison.cpp: In function âint main()â: testComparison.cpp:9:12: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare] if(x == y) so it appears to have difficulty seeing this issue if wrapped in a template/macro. bfs-dl360g7-27$ g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/gcc-4.8.2/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.8.2/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ./configure --prefix=/opt/gcc-4.8.2 --enable-languages=c,c++ --with-mpc=/opt/gcc-4.8.2 --with-mpfr=/opt/gcc-4.8.2 --with-gmp=/opt/gcc-.8.2 --with-cloog=/opt/gcc-4.8.2 --with-isl=/opt/gcc-4.8.2 Thread model: posix gcc version 4.8.2 (GCC) preprocessed file attached - apologies if i've missed anything vital or a bug already raised. rgds >From gcc-bugs-return-435371-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Nov 21 12:47:56 2013 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 12488 invoked by alias); 21 Nov 2013 12:47:55 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 12405 invoked by uid 48); 21 Nov 2013 12:47:51 -0000 From: "dominiq at lps dot ens.fr" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/59233] New: [4.9 Regression] C++ failures after revision 205058 on x86_64-apple-darwin13 with -m32 Date: Thu, 21 Nov 2013 12:47:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dominiq at lps dot ens.fr X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc cf_gcchost cf_gcctarget cf_gccbuild attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-11/txt/msg02148.txt.bz2 Content-length: 2425 http://gcc.gnu.org/bugzilla/show_bug.cgi?idY233 Bug ID: 59233 Summary: [4.9 Regression] C++ failures after revision 205058 on x86_64-apple-darwin13 with -m32 Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: dominiq at lps dot ens.fr CC: iains at gcc dot gnu.org, tejohnson at gcc dot gnu.org Host: x86_64-apple-darwin13 Target: x86_64-apple-darwin13 Build: x86_64-apple-darwin13 Created attachment 31262 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id1262&actioníit Preprocessed file for g++.dg/torture/pr52772.C The following failures appeared on x86_64-apple-darwin13 with -m32 after revision 205058 (205507 is OK): FAIL: g++.dg/opt/pr57661.C (internal compiler error) FAIL: g++.dg/opt/pr57661.C (test for excess errors) FAIL: g++.dg/torture/pr52772.C -Os (internal compiler error) FAIL: g++.dg/torture/pr52772.C -Os (test for excess errors) FAIL: 23_containers/list/debug/invalidation/4.cc (test for excess errors) UNRESOLVED: 23_containers/list/debug/invalidation/4.cc compilation failed to produce executable FAIL: ext/rope/2.cc (test for excess errors) UNRESOLVED: ext/rope/2.cc compilation failed to produce executable FAIL: ext/rope/5.cc (test for excess errors) [Book15] f90/bug% g++ -c pr52772.ii -m32 -Os /opt/gcc/work/gcc/testsuite/g++.dg/torture/pr52772.C: In member function 'int c8::tria(c7*, c5*)': /opt/gcc/work/gcc/testsuite/g++.dg/torture/pr52772.C:85:1: internal compiler error: Segmentation fault: 11 } ^ /opt/gcc/work/gcc/testsuite/g++.dg/torture/pr52772.C:85:1: internal compiler error: Abort trap: 6 g++: internal compiler error: Abort trap: 6 (program cc1plus) Abort [Book15] f90/bug% g++ -c pr57661.ii -m32 -O2 -fno-tree-forwprop -std=gnu++11 /opt/gcc/work/gcc/testsuite/g++.dg/opt/pr57661.C: In destructor 'I::~I() [with U = char; V = C]': /opt/gcc/work/gcc/testsuite/g++.dg/opt/pr57661.C:50:3: internal compiler error: Segmentation fault: 11 } ^ /opt/gcc/work/gcc/testsuite/g++.dg/opt/pr57661.C:50:3: internal compiler error: Abort trap: 6 g++: internal compiler error: Abort trap: 6 (program cc1plus) Abort I am attaching the preprocessed file for g++.dg/torture/pr52772.C.