* [Bug c++/52145] [C++11] zero-valued integer constant expression should prefer conversion to pointer
2012-02-07 1:00 [Bug c++/52145] New: [C++11] zero-valued integer constant expression should prefer conversion to pointer zeratul976 at hotmail dot com
@ 2012-02-07 13:52 ` daniel.kruegler at googlemail dot com
2012-02-07 14:39 ` [Bug c++/52145] [C++11] [DR 903] " redi at gcc dot gnu.org
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2012-02-07 13:52 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52145
Daniel Krügler <daniel.kruegler at googlemail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |daniel.kruegler at
| |googlemail dot com
--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2012-02-07 13:51:59 UTC ---
(In reply to comment #0)
The core language is in the process to make it clear, that S().n no longer is a
null-pointer constant, see
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#903
This would mean that the current behaviour is as intended. I would make the
outcome of this issue dependent on the final CWG 903 decision.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/52145] [C++11] [DR 903] zero-valued integer constant expression should prefer conversion to pointer
2012-02-07 1:00 [Bug c++/52145] New: [C++11] zero-valued integer constant expression should prefer conversion to pointer zeratul976 at hotmail dot com
2012-02-07 13:52 ` [Bug c++/52145] " daniel.kruegler at googlemail dot com
@ 2012-02-07 14:39 ` redi at gcc dot gnu.org
2012-04-26 19:43 ` jyasskin at gcc dot gnu.org
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2012-02-07 14:39 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52145
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |SUSPENDED
Last reconfirmed| |2012-02-07
Summary|[C++11] zero-valued integer |[C++11] [DR 903]
|constant expression should |zero-valued integer
|prefer conversion to |constant expression should
|pointer |prefer conversion to
| |pointer
Ever Confirmed|0 |1
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-02-07 14:39:07 UTC ---
suspending
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/52145] [C++11] [DR 903] zero-valued integer constant expression should prefer conversion to pointer
2012-02-07 1:00 [Bug c++/52145] New: [C++11] zero-valued integer constant expression should prefer conversion to pointer zeratul976 at hotmail dot com
2012-02-07 13:52 ` [Bug c++/52145] " daniel.kruegler at googlemail dot com
2012-02-07 14:39 ` [Bug c++/52145] [C++11] [DR 903] " redi at gcc dot gnu.org
@ 2012-04-26 19:43 ` jyasskin at gcc dot gnu.org
2012-04-26 23:03 ` paolo.carlini at oracle dot com
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jyasskin at gcc dot gnu.org @ 2012-04-26 19:43 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52145
Jeffrey Yasskin <jyasskin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|SUSPENDED |NEW
CC| |jyasskin at gcc dot gnu.org
--- Comment #3 from Jeffrey Yasskin <jyasskin at gcc dot gnu.org> 2012-04-26 19:42:19 UTC ---
A simpler test case is:
$ cat test.cc
const long kNullPtr = 0;
const long* ptr = kNullPtr;
$ g++-4.7pre -c test.cc -std=gnu++11
test.cc:2:19: error: invalid conversion from ‘long int’ to ‘const long int*’
[-fpermissive]
$ g++-4.7pre --version
g++-4.7pre (GCC) 4.7.1 20120412 (prerelease)
I'm going to unsuspend this because DR903 is "ready", and gcc-4.7's behavior
doesn't match either the proposed wording or the current definition of C++11.
The proposed wording discusses a change to C++17 rather than to C++11 (we can
tell because it adds a "C.3 C++ and ISO C++ 2011" section), so the new error
should only show up under -std=gnu++17, and be a warning in -std=gnu++11.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/52145] [C++11] [DR 903] zero-valued integer constant expression should prefer conversion to pointer
2012-02-07 1:00 [Bug c++/52145] New: [C++11] zero-valued integer constant expression should prefer conversion to pointer zeratul976 at hotmail dot com
` (2 preceding siblings ...)
2012-04-26 19:43 ` jyasskin at gcc dot gnu.org
@ 2012-04-26 23:03 ` paolo.carlini at oracle dot com
2012-04-26 23:06 ` jyasskin at gcc dot gnu.org
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-04-26 23:03 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52145
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |paolo.carlini at oracle dot
| |com
--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-04-26 23:03:11 UTC ---
17?
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/52145] [C++11] [DR 903] zero-valued integer constant expression should prefer conversion to pointer
2012-02-07 1:00 [Bug c++/52145] New: [C++11] zero-valued integer constant expression should prefer conversion to pointer zeratul976 at hotmail dot com
` (3 preceding siblings ...)
2012-04-26 23:03 ` paolo.carlini at oracle dot com
@ 2012-04-26 23:06 ` jyasskin at gcc dot gnu.org
2012-04-26 23:14 ` paolo.carlini at oracle dot com
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jyasskin at gcc dot gnu.org @ 2012-04-26 23:06 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52145
--- Comment #5 from Jeffrey Yasskin <jyasskin at gcc dot gnu.org> 2012-04-26 23:06:05 UTC ---
"17" was the rough consensus at Kona for the target for the next standard. You
could use -std=c++1y or c++1x or whatever instead.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/52145] [C++11] [DR 903] zero-valued integer constant expression should prefer conversion to pointer
2012-02-07 1:00 [Bug c++/52145] New: [C++11] zero-valued integer constant expression should prefer conversion to pointer zeratul976 at hotmail dot com
` (4 preceding siblings ...)
2012-04-26 23:06 ` jyasskin at gcc dot gnu.org
@ 2012-04-26 23:14 ` paolo.carlini at oracle dot com
2012-04-26 23:57 ` jyasskin at gcc dot gnu.org
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-04-26 23:14 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52145
--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-04-26 23:14:18 UTC ---
Oh, Ok, I wasn't there. In GCC we currently use -std=c++1y, but you know that.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/52145] [C++11] [DR 903] zero-valued integer constant expression should prefer conversion to pointer
2012-02-07 1:00 [Bug c++/52145] New: [C++11] zero-valued integer constant expression should prefer conversion to pointer zeratul976 at hotmail dot com
` (5 preceding siblings ...)
2012-04-26 23:14 ` paolo.carlini at oracle dot com
@ 2012-04-26 23:57 ` jyasskin at gcc dot gnu.org
2014-12-10 13:30 ` redi at gcc dot gnu.org
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jyasskin at gcc dot gnu.org @ 2012-04-26 23:57 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52145
--- Comment #7 from Jeffrey Yasskin <jyasskin at gcc dot gnu.org> 2012-04-26 23:56:22 UTC ---
Oops, I didn't actually realize you'd allocated an option for that in 4.8, and
was just making one up. Sorry for the distraction.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/52145] [C++11] [DR 903] zero-valued integer constant expression should prefer conversion to pointer
2012-02-07 1:00 [Bug c++/52145] New: [C++11] zero-valued integer constant expression should prefer conversion to pointer zeratul976 at hotmail dot com
` (6 preceding siblings ...)
2012-04-26 23:57 ` jyasskin at gcc dot gnu.org
@ 2014-12-10 13:30 ` redi at gcc dot gnu.org
2021-12-04 6:43 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2014-12-10 13:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52145
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |accepts-invalid
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
DR 903 is a DR against C++11 ([diff.cpp03.conv] identifies it as an
incompatibility with C++03, not with C++11).
Clang also implements DR 903 in C++11 mode.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/52145] [C++11] [DR 903] zero-valued integer constant expression should prefer conversion to pointer
2012-02-07 1:00 [Bug c++/52145] New: [C++11] zero-valued integer constant expression should prefer conversion to pointer zeratul976 at hotmail dot com
` (7 preceding siblings ...)
2014-12-10 13:30 ` redi at gcc dot gnu.org
@ 2021-12-04 6:43 ` pinskia at gcc dot gnu.org
2021-12-04 6:43 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-04 6:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52145
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dominique.pelle at gmail dot com
--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 88655 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/52145] [C++11] [DR 903] zero-valued integer constant expression should prefer conversion to pointer
2012-02-07 1:00 [Bug c++/52145] New: [C++11] zero-valued integer constant expression should prefer conversion to pointer zeratul976 at hotmail dot com
` (8 preceding siblings ...)
2021-12-04 6:43 ` pinskia at gcc dot gnu.org
@ 2021-12-04 6:43 ` pinskia at gcc dot gnu.org
2021-12-04 6:52 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-04 6:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52145
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rs2740 at gmail dot com
--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 77712 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/52145] [C++11] [DR 903] zero-valued integer constant expression should prefer conversion to pointer
2012-02-07 1:00 [Bug c++/52145] New: [C++11] zero-valued integer constant expression should prefer conversion to pointer zeratul976 at hotmail dot com
` (9 preceding siblings ...)
2021-12-04 6:43 ` pinskia at gcc dot gnu.org
@ 2021-12-04 6:52 ` pinskia at gcc dot gnu.org
2021-12-07 12:39 ` pinskia at gcc dot gnu.org
2022-10-14 15:14 ` pinskia at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-04 6:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52145
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Blocks|88655 |94404
Alias| |cwg903
--- Comment #11 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Here is a testcase which tests all of the null pointerness in C++11 (+):
#include <cstddef>
extern "C" int puts(const char*);
typedef unsigned long uint64_t;
typedef long int64_t;
struct Foo { Foo(int64_t) { } };
bool t = true;
void foo(const char*)
{
if (t)
__builtin_abort();
puts("In foo(const char*)");
}
void foo(const Foo&)
{
if (!t)
__builtin_abort();
puts("In foo(const Foo&)");
}
int main()
{
#if __cplusplus >= 201103L
t= true;
#else
t= false;
#endif
foo((int)0);
foo((unsigned)0);
foo((short)0);
foo((unsigned short)0);
foo((int64_t)0);
foo((uint64_t)0);
foo(int());
#if __cplusplus >= 201103L
foo(int{});
t= false;
foo(nullptr);
#endif
foo(0u);
foo(0ul);
foo(0ull);
foo(0);
foo(NULL);
}
---- CUT ----
We get this right for C++98 but wrong for C++11.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88655
[Bug 88655] Different overloaded function being called depending on which
compiler is used
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94404
[Bug 94404] [meta-bug] C++ core issues
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/52145] [C++11] [DR 903] zero-valued integer constant expression should prefer conversion to pointer
2012-02-07 1:00 [Bug c++/52145] New: [C++11] zero-valued integer constant expression should prefer conversion to pointer zeratul976 at hotmail dot com
` (10 preceding siblings ...)
2021-12-04 6:52 ` pinskia at gcc dot gnu.org
@ 2021-12-07 12:39 ` pinskia at gcc dot gnu.org
2022-10-14 15:14 ` pinskia at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-07 12:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52145
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |darktemplar at basealt dot ru
--- Comment #12 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 96761 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/52145] [C++11] [DR 903] zero-valued integer constant expression should prefer conversion to pointer
2012-02-07 1:00 [Bug c++/52145] New: [C++11] zero-valued integer constant expression should prefer conversion to pointer zeratul976 at hotmail dot com
` (11 preceding siblings ...)
2021-12-07 12:39 ` pinskia at gcc dot gnu.org
@ 2022-10-14 15:14 ` pinskia at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-14 15:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52145
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |xmh970252187 at gmail dot com
--- Comment #13 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 107260 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 14+ messages in thread