public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107260] New: The prvalue with the value 0 that is not a integer literal shouldn't convert to std::nullptr_t
@ 2022-10-14  9:35 xmh970252187 at gmail dot com
  2022-10-14  9:59 ` [Bug c++/107260] " redi at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: xmh970252187 at gmail dot com @ 2022-10-14  9:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107260

            Bug ID: 107260
           Summary: The prvalue with the value 0 that is not a integer
                    literal shouldn't convert to std::nullptr_t
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xmh970252187 at gmail dot com
  Target Milestone: ---

[conv.ptr] p1 says
> A null pointer constant is an integer literal ([lex.icon]) with value zero 

> A null pointer constant of integral type can be converted to a prvalue of type std​::​nullptr_­t.

GCC accept this example
````cpp
std::nullptr_t v = (int)0;
````
However, the initializer expression is not an integer literal, it is a prvalue
of integer type with the value 0. It should be rejected. Clang rejects this
example. https://godbolt.org/z/fxMo4YKE3

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/107260] The prvalue with the value 0 that is not a integer literal shouldn't convert to std::nullptr_t
  2022-10-14  9:35 [Bug c++/107260] New: The prvalue with the value 0 that is not a integer literal shouldn't convert to std::nullptr_t xmh970252187 at gmail dot com
@ 2022-10-14  9:59 ` redi at gcc dot gnu.org
  2022-10-14 13:21 ` mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2022-10-14  9:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107260

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2022-10-14
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to jim x from comment #0)
> GCC accept this example

Well, it does if you include a definition of std::nullptr_t

typedef decltype(nullptr) nullptr_t;
nullptr_t v = (int)0;

Not a regression, this has been accepted since 4.6.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/107260] The prvalue with the value 0 that is not a integer literal shouldn't convert to std::nullptr_t
  2022-10-14  9:35 [Bug c++/107260] New: The prvalue with the value 0 that is not a integer literal shouldn't convert to std::nullptr_t xmh970252187 at gmail dot com
  2022-10-14  9:59 ` [Bug c++/107260] " redi at gcc dot gnu.org
@ 2022-10-14 13:21 ` mpolacek at gcc dot gnu.org
  2022-10-14 13:52 ` mpolacek at gcc dot gnu.org
  2022-10-14 15:14 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-10-14 13:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107260

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I think this is CWG 903 and thus a dup of bug 52145.  The problem here is
probably the same as I described in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77712#c2.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/107260] The prvalue with the value 0 that is not a integer literal shouldn't convert to std::nullptr_t
  2022-10-14  9:35 [Bug c++/107260] New: The prvalue with the value 0 that is not a integer literal shouldn't convert to std::nullptr_t xmh970252187 at gmail dot com
  2022-10-14  9:59 ` [Bug c++/107260] " redi at gcc dot gnu.org
  2022-10-14 13:21 ` mpolacek at gcc dot gnu.org
@ 2022-10-14 13:52 ` mpolacek at gcc dot gnu.org
  2022-10-14 15:14 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-10-14 13:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107260

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I wonder if we could wrap the INTEGER_CST in a NOP_EXPR/V_C_E to make it clear
it's not an integer literal.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/107260] The prvalue with the value 0 that is not a integer literal shouldn't convert to std::nullptr_t
  2022-10-14  9:35 [Bug c++/107260] New: The prvalue with the value 0 that is not a integer literal shouldn't convert to std::nullptr_t xmh970252187 at gmail dot com
                   ` (2 preceding siblings ...)
  2022-10-14 13:52 ` mpolacek at gcc dot gnu.org
@ 2022-10-14 15:14 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ 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=107260

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 52145.

*** This bug has been marked as a duplicate of bug 52145 ***

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-10-14 15:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-14  9:35 [Bug c++/107260] New: The prvalue with the value 0 that is not a integer literal shouldn't convert to std::nullptr_t xmh970252187 at gmail dot com
2022-10-14  9:59 ` [Bug c++/107260] " redi at gcc dot gnu.org
2022-10-14 13:21 ` mpolacek at gcc dot gnu.org
2022-10-14 13:52 ` mpolacek at gcc dot gnu.org
2022-10-14 15:14 ` 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).