public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99524] New: initializer_list storage considered a temporary when accessed through NTTP
@ 2021-03-10 18:08 johelegp at gmail dot com
  2023-11-16  0:49 ` [Bug c++/99524] " arthur.j.odwyer at gmail dot com
  2023-11-16  0:51 ` johelegp at gmail dot com
  0 siblings, 2 replies; 3+ messages in thread
From: johelegp at gmail dot com @ 2021-03-10 18:08 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99524
           Summary: initializer_list storage considered a temporary when
                    accessed through NTTP
           Product: gcc
           Version: 11.0
               URL: https://godbolt.org/z/aWGr3P
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: johelegp at gmail dot com
                CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/aWGr3P.
```C++
#include<initializer_list>
constexpr std::initializer_list<bool>il{true};
template<const bool*B>constexpr bool front=B[0];
static_assert(front<il.begin()>);
```
https://timsong-cpp.github.io/cppwp/n4861/dcl.init.list#5 explains its storage.
https://timsong-cpp.github.io/cppwp/n4861/dcl.init.list#6 explains its
lifetime.

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

* [Bug c++/99524] initializer_list storage considered a temporary when accessed through NTTP
  2021-03-10 18:08 [Bug c++/99524] New: initializer_list storage considered a temporary when accessed through NTTP johelegp at gmail dot com
@ 2023-11-16  0:49 ` arthur.j.odwyer at gmail dot com
  2023-11-16  0:51 ` johelegp at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: arthur.j.odwyer at gmail dot com @ 2023-11-16  0:49 UTC (permalink / raw)
  To: gcc-bugs

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

Arthur O'Dwyer <arthur.j.odwyer at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |arthur.j.odwyer at gmail dot com

--- Comment #1 from Arthur O'Dwyer <arthur.j.odwyer at gmail dot com> ---
I don't see this as a bug (and indeed Clang/MSVC reject it too). It's okay to
use the address of `il` itself as the value of a template parameter, because we
know a mangleable name for that; but the address of the first element of the
backing array isn't a valid value for a template parameter, because the backing
array is anonymous — it hasn't got a mangleable name — in the
very-new-like-as-of-last-week Standardese, it's a "potentially non-unique
object." The same rejection applies to this example employing a string literal
(the other kind of "potentially non-unique object") in the Standard
post-CWG2753):

constexpr const char *il = "hello world";
template<auto*> constexpr bool front = true;
static_assert(front<&il>);     // OK
static_assert(front<&il[0]>);  // Reject

So I think this is not-a-bug.

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

* [Bug c++/99524] initializer_list storage considered a temporary when accessed through NTTP
  2021-03-10 18:08 [Bug c++/99524] New: initializer_list storage considered a temporary when accessed through NTTP johelegp at gmail dot com
  2023-11-16  0:49 ` [Bug c++/99524] " arthur.j.odwyer at gmail dot com
@ 2023-11-16  0:51 ` johelegp at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: johelegp at gmail dot com @ 2023-11-16  0:51 UTC (permalink / raw)
  To: gcc-bugs

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

Johel Ernesto Guerrero Peña <johelegp at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #2 from Johel Ernesto Guerrero Peña <johelegp at gmail dot com> ---
Thank you.
Let's close this then.

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

end of thread, other threads:[~2023-11-16  0:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-10 18:08 [Bug c++/99524] New: initializer_list storage considered a temporary when accessed through NTTP johelegp at gmail dot com
2023-11-16  0:49 ` [Bug c++/99524] " arthur.j.odwyer at gmail dot com
2023-11-16  0:51 ` johelegp at gmail dot com

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).