From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26532 invoked by alias); 6 Jan 2014 21:08:52 -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 26514 invoked by uid 48); 6 Jan 2014 21:08:46 -0000 From: "ambrus at math dot bme.hu" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/59704] New: Wrong overload chosen, compiler errornously thinks non-constant zero expression is implicitly castable to null pointer Date: Mon, 06 Jan 2014 21:08: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: ambrus at math dot bme.hu 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: 2014-01/txt/msg00569.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D59704 Bug ID: 59704 Summary: Wrong overload chosen, compiler errornously thinks non-constant zero expression is implicitly castable to null pointer Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ambrus at math dot bme.hu Created attachment 31759 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=3D31759&action=3Dedit preprocessed C++ source file Gcc gives an error compiling the attached C++ file, despite that the code is valid and should compile.=20=20 The error message claims that I am trying to call the first (non-vararg) overload of the function covl, which is deleted. In reality, the code shou= ld be calling the second (vararg) overload of the function. The second argume= nt in the call is an integral typed expression that is not a constant expressi= on, and so it cannot be implicitly converted to a pointer and cannot match the parameter in the first overload of the function covl. Although the express= ion (v - v) would always have a value of zero in this context, the expression contains lvalue-to-rvalue conversion of a non-const variable, which makes t= his expression not count as a constant expression according to tha language rul= es.=20 Thus, the call should fall back to use the second overload of the function covl, which it does match. I am using gcc 4.8.1 compiled from vanilla sources, on a linux-x86_64 syste= m.=20 The command line is g++ -v -c -std=3Dc++11 -x c++-cpp-output zerocast.ii The preprocessed C++ source file should be attached to this ticket. Below = you can see the full output of g++, including the configuration options. $ cat zerocast.ii # 1 "zerocast.cxx" # 1 "" # 1 "zerocast.cxx" void covl(int d, void *v) =3D delete; void covl(int d, ...); void bspr(unsigned v) { covl(0, v - v); } $ g++ -v -c -std=3Dc++11 -x c++-cpp-output zerocast.ii Using built-in specs. COLLECT_GCC=3Dg++ Target: x86_64-unknown-linux-gnu Configured with: ../gcc-4.8.1/configure --prefix=3D/usr/local/gcc481 -with-gmp=3D/usr/local -with-mpfr=3D/usr/local -with-mpc=3D/usr/local --enable-languages=3Dc,c++,fortran Thread model: posix gcc version 4.8.1 (GCC)=20 COLLECT_GCC_OPTIONS=3D'-v' '-c' '-std=3Dc++11' '-shared-libgcc' '-mtune=3Dg= eneric' '-march=3Dx86-64' /usr/local/gcc481/libexec/gcc/x86_64-unknown-linux-gnu/4.8.1/cc1plus -fpreprocessed zerocast.ii -quiet -dumpbase zerocast.ii -mtune=3Dgeneric -march=3Dx86-64 -auxbase zerocast -std=3Dc++11 -version -o /tmp/ccgVThJQ.s GNU C++ (GCC) version 4.8.1 (x86_64-unknown-linux-gnu) compiled by GNU C version 4.8.1, GMP version 5.0.1, MPFR version 3.0.0-= p3, MPC version 0.8.2 GGC heuristics: --param ggc-min-expand=3D98 --param ggc-min-heapsize=3D1274= 09 GNU C++ (GCC) version 4.8.1 (x86_64-unknown-linux-gnu) compiled by GNU C version 4.8.1, GMP version 5.0.1, MPFR version 3.0.0-= p3, MPC version 0.8.2 GGC heuristics: --param ggc-min-expand=3D98 --param ggc-min-heapsize=3D1274= 09 Compiler executable checksum: 47191b782ec6877222820ebb50c2fe12 zerocast.cxx: In function =E2=80=98void bspr(unsigned int)=E2=80=99: zerocast.cxx:5:15: error: use of deleted function =E2=80=98void covl(int, v= oid*)=E2=80=99 covl(0, v - v); ^ zerocast.cxx:2:6: error: declared here void covl(int d, void *v) =3D delete; ^ $ >>From gcc-bugs-return-439428-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Jan 06 21:14:56 2014 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 30410 invoked by alias); 6 Jan 2014 21:14:56 -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 29890 invoked by uid 48); 6 Jan 2014 21:14:51 -0000 From: "reichelt at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/59629] [4.9 Regression] [c++11] ICE with invalid use of auto in lambda function Date: Mon, 06 Jan 2014 21:14:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: ice-on-invalid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: reichelt at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.9.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status resolution target_milestone 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: 2014-01/txt/msg00570.txt.bz2 Content-length: 516 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59629 Volker Reichelt changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |FIXED Target Milestone|--- |4.9.0 --- Comment #2 from Volker Reichelt --- Fixed for GCC 4.9.0 by Adam's patch.