From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1205 invoked by alias); 21 Oct 2013 09:23:10 -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 Received: (qmail 1173 invoked by uid 48); 21 Oct 2013 09:23:06 -0000 From: "thomas.sanchz at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/58824] New: Lambda trigger internal compiler error Date: Mon, 21 Oct 2013 09:23: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.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: thomas.sanchz at gmail dot com 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 attachments.created 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-10/txt/msg01463.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D58824 Bug ID: 58824 Summary: Lambda trigger internal compiler error Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: thomas.sanchz at gmail dot com Created attachment 31058 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=3D31058&action=3Dedit Source file + ii + s Hi, Please see in attached file the source triggering an internal error in gcc. The source file is compiled like this: $> g++ -std=3Dc++11 -W -Wall -Wextra test.cpp=20 test.cpp: In instantiation of =E2=80=98struct test::__lambda0=E2=80= =99: test.cpp:5:8: required from here test.cpp:8:20: internal compiler error: in tsubst_copy, at cp/pt.c:12116 { "test", [this]{} } The bug is triggered when `this` is captured from a template class and the lambda is assigned directly from the class definition. The platform tested is an ubuntu 13.10 with default shipped compiler: $gcc -v Using built-in specs. COLLECT_GCC=3Dgcc COLLECT_LTO_WRAPPER=3D/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion=3D'Ubuntu/Linaro 4.8.1-10ubuntu8' --with-bugurl=3Dfile:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=3Dc,c++,java,go,d,fortran,objc,obj-c++ --prefix=3D/usr --program-suffix=3D-4.8 --enable-shared --enable-linker-build-id --libexecdir=3D/usr/lib --without-included-gettext --enable-threads=3Dposix --with-gxx-include-dir=3D/usr/include/c++/4.8 --libdir=3D/usr/lib --enable-= nls --with-sysroot=3D/ --enable-clocale=3Dgnu --enable-libstdcxx-debug --enable-libstdcxx-time=3Dyes --enable-gnu-unique-object --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=3Dgtk --enable-gtk-cairo --with-java-home=3D/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64= /jre --enable-java-home --with-jvm-root-dir=3D/usr/lib/jvm/java-1.5.0-gcj-4.8-am= d64 --with-jvm-jar-dir=3D/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=3Damd64 --with-ecj-jar=3D/usr/share/java/eclipse-ecj.= jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=3Di686 --with-abi=3Dm64 --with-multilib-list=3Dm32,m64,mx32 --with-tune=3Dgeneric --enable-checking=3Drelease --build=3Dx86_64-linux-gnu --host=3Dx86_64-linu= x-gnu --target=3Dx86_64-linux-gnu Thread model: posix gcc version 4.8.1 (Ubuntu/Linaro 4.8.1-10ubuntu8)=20 The bug is still present in gcc4.9 (tested via: http://gcc.godbolt.org/). I joined the *i files even if I doubt that they'll be helpful in this particular bug. >>From gcc-bugs-return-432321-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Oct 21 09:24:41 2013 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 2773 invoked by alias); 21 Oct 2013 09:24:40 -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 2399 invoked by uid 48); 21 Oct 2013 09:24:36 -0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/58742] [4.7/4.8/4.9 Regression] pointer arithmetic simplification Date: Mon, 21 Oct 2013 09:24:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.7.4 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: component cf_known_to_work target_milestone short_desc cf_known_to_fail Message-ID: In-Reply-To: References: 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-10/txt/msg01465.txt.bz2 Content-length: 2162 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58742 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Component|tree-optimization |middle-end Known to work| |4.1.2 Target Milestone|--- |4.7.4 Summary|pointer arithmetic |[4.7/4.8/4.9 Regression] |simplification |pointer arithmetic | |simplification Known to fail| |4.2.0 --- Comment #3 from Richard Biener --- This case is a signed exact division followed by an unsigned multiply. We do that to avoid introducing undefined signed overflow. signed exact division and unsigned multiply still cancel out though, handling of these is in extract_muldiv (ugh). I'm not going to enhance that but pattern match this case. Testing Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c (revision 203885) +++ gcc/fold-const.c (working copy) @@ -11002,6 +11002,13 @@ fold_binary_loc (location_t loc, fold_build2_loc (loc, MULT_EXPR, type, build_int_cst (type, 2) , arg1)); + /* ((T) (X /[ex] C)) * C cancels out if the conversion is + sign-changing only. */ + if (TREE_CODE (arg1) == INTEGER_CST + && TREE_CODE (arg0) == EXACT_DIV_EXPR + && operand_equal_p (arg1, TREE_OPERAND (arg0, 1), 0)) + return fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0)); + strict_overflow_p = false; if (TREE_CODE (arg1) == INTEGER_CST && 0 != (tem = extract_muldiv (op0, arg1, code, NULL_TREE, note that this simplification worked in 4.1.2 but stopped working in 4.2.0. Likely a wrong-code fix for extract_muldiv disabled this case (the way that function works makes special casing a pattern like above impossible).