public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/110493] New: 'is not a constant expression' for function-local static std::initializer_list<std::string> with fsanitize=undefined
@ 2023-06-30  4:29 ed at catmur dot uk
  2023-06-30  4:32 ` [Bug libstdc++/110493] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: ed at catmur dot uk @ 2023-06-30  4:29 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110493
           Summary: 'is not a constant expression' for function-local
                    static std::initializer_list<std::string> with
                    fsanitize=undefined
           Product: gcc
           Version: 12.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ed at catmur dot uk
  Target Milestone: ---

Since 12.3.0, under -fsanitize=undefined -std=c++20:

#include <initializer_list>
#include <string>
void f() {
    static auto a = {std::string()};
}

error: '(((const std::__cxx11::basic_string<char>*)(& <temporary>)) != 0)' is
not a constant expression

Clearly this is an instance of bug 71962, but this is in fairly unexceptional
code and could make ubsan unusable; it's not obvious that this code should have
anything to do with constant evaluation.

Since it only appears in a point release I would hope it might be possible to
fix in library for this specific case, within <initializer_list>?

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

* [Bug libstdc++/110493] 'is not a constant expression' for function-local static std::initializer_list<std::string> with fsanitize=undefined
  2023-06-30  4:29 [Bug libstdc++/110493] New: 'is not a constant expression' for function-local static std::initializer_list<std::string> with fsanitize=undefined ed at catmur dot uk
@ 2023-06-30  4:32 ` pinskia at gcc dot gnu.org
  2023-06-30  4:42 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-30  4:32 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
std::string::string is a constexpr in C++20 ...

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

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

* [Bug libstdc++/110493] 'is not a constant expression' for function-local static std::initializer_list<std::string> with fsanitize=undefined
  2023-06-30  4:29 [Bug libstdc++/110493] New: 'is not a constant expression' for function-local static std::initializer_list<std::string> with fsanitize=undefined ed at catmur dot uk
  2023-06-30  4:32 ` [Bug libstdc++/110493] " pinskia at gcc dot gnu.org
@ 2023-06-30  4:42 ` pinskia at gcc dot gnu.org
  2023-06-30  4:42 ` [Bug c++/110493] " pinskia at gcc dot gnu.org
  2023-06-30  7:49 ` ed at catmur dot uk
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-30  4:42 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|DUPLICATE                   |---
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=107079
             Status|RESOLVED                    |UNCONFIRMED

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Actually let's reopen this ...

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

* [Bug c++/110493] 'is not a constant expression' for function-local static std::initializer_list<std::string> with fsanitize=undefined
  2023-06-30  4:29 [Bug libstdc++/110493] New: 'is not a constant expression' for function-local static std::initializer_list<std::string> with fsanitize=undefined ed at catmur dot uk
  2023-06-30  4:32 ` [Bug libstdc++/110493] " pinskia at gcc dot gnu.org
  2023-06-30  4:42 ` pinskia at gcc dot gnu.org
@ 2023-06-30  4:42 ` pinskia at gcc dot gnu.org
  2023-06-30  7:49 ` ed at catmur dot uk
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-30  4:42 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|libstdc++                   |c++

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note it was not libstdc++ that changed but the front-end (PR 107079  ).

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

* [Bug c++/110493] 'is not a constant expression' for function-local static std::initializer_list<std::string> with fsanitize=undefined
  2023-06-30  4:29 [Bug libstdc++/110493] New: 'is not a constant expression' for function-local static std::initializer_list<std::string> with fsanitize=undefined ed at catmur dot uk
                   ` (2 preceding siblings ...)
  2023-06-30  4:42 ` [Bug c++/110493] " pinskia at gcc dot gnu.org
@ 2023-06-30  7:49 ` ed at catmur dot uk
  3 siblings, 0 replies; 5+ messages in thread
From: ed at catmur dot uk @ 2023-06-30  7:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Ed Catmur <ed at catmur dot uk> ---
Ah, thanks. So a workaround is something like:

void f() { static auto a = {((bool*)&(int const&)0, std::string())}; }

That's not too bad, then.

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

end of thread, other threads:[~2023-06-30  7:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-30  4:29 [Bug libstdc++/110493] New: 'is not a constant expression' for function-local static std::initializer_list<std::string> with fsanitize=undefined ed at catmur dot uk
2023-06-30  4:32 ` [Bug libstdc++/110493] " pinskia at gcc dot gnu.org
2023-06-30  4:42 ` pinskia at gcc dot gnu.org
2023-06-30  4:42 ` [Bug c++/110493] " pinskia at gcc dot gnu.org
2023-06-30  7:49 ` ed at catmur dot uk

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