public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/59704] New: Wrong overload chosen, compiler errornously thinks non-constant zero expression is implicitly castable to null pointer
@ 2014-01-06 21:08 ambrus at math dot bme.hu
2014-01-09 17:38 ` [Bug c++/59704] " redi at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: ambrus at math dot bme.hu @ 2014-01-06 21:08 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59704
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=31759&action=edit
preprocessed C++ source file
Gcc gives an error compiling the attached C++ file, despite that the code is
valid and should compile.
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 should
be calling the second (vararg) overload of the function. The second argument
in the call is an integral typed expression that is not a constant expression,
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 expression
(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 this
expression not count as a constant expression according to tha language rules.
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 system.
The command line is
g++ -v -c -std=c++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 "<command-line>"
# 1 "zerocast.cxx"
void covl(int d, void *v) = delete;
void covl(int d, ...);
void bspr(unsigned v) {
covl(0, v - v);
}
$ g++ -v -c -std=c++11 -x c++-cpp-output zerocast.ii
Using built-in specs.
COLLECT_GCC=g++
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.8.1/configure --prefix=/usr/local/gcc481
-with-gmp=/usr/local -with-mpfr=/usr/local -with-mpc=/usr/local
--enable-languages=c,c++,fortran
Thread model: posix
gcc version 4.8.1 (GCC)
COLLECT_GCC_OPTIONS='-v' '-c' '-std=c++11' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'
/usr/local/gcc481/libexec/gcc/x86_64-unknown-linux-gnu/4.8.1/cc1plus
-fpreprocessed zerocast.ii -quiet -dumpbase zerocast.ii -mtune=generic
-march=x86-64 -auxbase zerocast -std=c++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=98 --param ggc-min-heapsize=127409
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=98 --param ggc-min-heapsize=127409
Compiler executable checksum: 47191b782ec6877222820ebb50c2fe12
zerocast.cxx: In function ‘void bspr(unsigned int)’:
zerocast.cxx:5:15: error: use of deleted function ‘void covl(int, void*)’
covl(0, v - v);
^
zerocast.cxx:2:6: error: declared here
void covl(int d, void *v) = delete;
^
$
>From gcc-bugs-return-439428-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Jan 06 21:14:56 2014
Return-Path: <gcc-bugs-return-439428-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
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: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
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" <gcc-bugzilla@gcc.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: <bug-59629-4-kCjLOpJJ76@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-59629-4@http.gcc.gnu.org/bugzilla/>
References: <bug-59629-4@http.gcc.gnu.org/bugzilla/>
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?idY629
Volker Reichelt <reichelt at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |FIXED
Target Milestone|--- |4.9.0
--- Comment #2 from Volker Reichelt <reichelt at gcc dot gnu.org> ---
Fixed for GCC 4.9.0 by Adam's patch.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/59704] Wrong overload chosen, compiler errornously thinks non-constant zero expression is implicitly castable to null pointer
2014-01-06 21:08 [Bug c++/59704] New: Wrong overload chosen, compiler errornously thinks non-constant zero expression is implicitly castable to null pointer ambrus at math dot bme.hu
@ 2014-01-09 17:38 ` redi at gcc dot gnu.org
2014-08-14 23:21 ` pangbw at gmail dot com
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2014-01-09 17:38 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59704
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-01-09
Ever confirmed|0 |1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/59704] Wrong overload chosen, compiler errornously thinks non-constant zero expression is implicitly castable to null pointer
2014-01-06 21:08 [Bug c++/59704] New: Wrong overload chosen, compiler errornously thinks non-constant zero expression is implicitly castable to null pointer ambrus at math dot bme.hu
2014-01-09 17:38 ` [Bug c++/59704] " redi at gcc dot gnu.org
@ 2014-08-14 23:21 ` pangbw at gmail dot com
2021-12-04 6:57 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pangbw at gmail dot com @ 2014-08-14 23:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59704
baoshan <pangbw at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pangbw at gmail dot com
--- Comment #1 from baoshan <pangbw at gmail dot com> ---
*** Bug 62145 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/59704] Wrong overload chosen, compiler errornously thinks non-constant zero expression is implicitly castable to null pointer
2014-01-06 21:08 [Bug c++/59704] New: Wrong overload chosen, compiler errornously thinks non-constant zero expression is implicitly castable to null pointer ambrus at math dot bme.hu
2014-01-09 17:38 ` [Bug c++/59704] " redi at gcc dot gnu.org
2014-08-14 23:21 ` pangbw at gmail dot com
@ 2021-12-04 6:57 ` pinskia at gcc dot gnu.org
2021-12-04 7:12 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-04 6:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59704
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Arthur O'Dwyer from comment #2)
> Here is another example:
> https://wandbox.org/permlink/UYsLyMaLcBb6sjJa
That is PR 52145.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/59704] Wrong overload chosen, compiler errornously thinks non-constant zero expression is implicitly castable to null pointer
2014-01-06 21:08 [Bug c++/59704] New: Wrong overload chosen, compiler errornously thinks non-constant zero expression is implicitly castable to null pointer ambrus at math dot bme.hu
` (2 preceding siblings ...)
2021-12-04 6:57 ` pinskia at gcc dot gnu.org
@ 2021-12-04 7:12 ` pinskia at gcc dot gnu.org
2021-12-09 9:26 ` marxin at gcc dot gnu.org
2021-12-09 14:40 ` pinskia at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-04 7:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59704
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |needs-bisection
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The oiriginal testcase in comment #0 and the testcase in the dup (PR 62145) are
fixed in GCC 6+.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/59704] Wrong overload chosen, compiler errornously thinks non-constant zero expression is implicitly castable to null pointer
2014-01-06 21:08 [Bug c++/59704] New: Wrong overload chosen, compiler errornously thinks non-constant zero expression is implicitly castable to null pointer ambrus at math dot bme.hu
` (3 preceding siblings ...)
2021-12-04 7:12 ` pinskia at gcc dot gnu.org
@ 2021-12-09 9:26 ` marxin at gcc dot gnu.org
2021-12-09 14:40 ` pinskia at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-12-09 9:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59704
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |marxin at gcc dot gnu.org
Resolution|--- |FIXED
--- Comment #5 from Martin Liška <marxin at gcc dot gnu.org> ---
Fixed with r6-4886-gcda0a029f45d20f4.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/59704] Wrong overload chosen, compiler errornously thinks non-constant zero expression is implicitly castable to null pointer
2014-01-06 21:08 [Bug c++/59704] New: Wrong overload chosen, compiler errornously thinks non-constant zero expression is implicitly castable to null pointer ambrus at math dot bme.hu
` (4 preceding siblings ...)
2021-12-09 9:26 ` marxin at gcc dot gnu.org
@ 2021-12-09 14:40 ` pinskia at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-09 14:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59704
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |6.0
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-12-09 14:40 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-06 21:08 [Bug c++/59704] New: Wrong overload chosen, compiler errornously thinks non-constant zero expression is implicitly castable to null pointer ambrus at math dot bme.hu
2014-01-09 17:38 ` [Bug c++/59704] " redi at gcc dot gnu.org
2014-08-14 23:21 ` pangbw at gmail dot com
2021-12-04 6:57 ` pinskia at gcc dot gnu.org
2021-12-04 7:12 ` pinskia at gcc dot gnu.org
2021-12-09 9:26 ` marxin at gcc dot gnu.org
2021-12-09 14:40 ` pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).