public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114913] New: "verify_gimple failed" due to addition of two constexpr strings
@ 2024-05-01 21:02 jorg.brown at gmail dot com
  2024-05-01 21:11 ` [Bug middle-end/114913] " pinskia at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: jorg.brown at gmail dot com @ 2024-05-01 21:02 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114913
           Summary: "verify_gimple failed" due to addition of two
                    constexpr strings
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jorg.brown at gmail dot com
  Target Milestone: ---

Source:

#include <string>

constexpr std::string Hello = "Hello, ", World = "World.";
constexpr std::string HelloWorld = Hello + World;

int main() { printf("%s\n", HelloWorld.c_str()); }

= - = - = - = - = - = - = - = - = - = - = - = - = - = - = - =

Version:

g++
(Compiler-Explorer-Build-gcc-610415bb7ddc5626ec301ca20833e78696978601-binutils-2.40)
15.0.0 20240501 (experimental)
Copyright (C) 2024 Free Software Foundation, Inc.

ASM generation compiler returned: 0
g++
(Compiler-Explorer-Build-gcc-610415bb7ddc5626ec301ca20833e78696978601-binutils-2.40)
15.0.0 20240501 (experimental)
Copyright (C) 2024 Free Software Foundation, Inc.

= - = - = - = - = - = - = - = - = - = - = - = - = - = - = - =

As seen at https://godbolt.org/z/hd1TbM61Y , I got:

<source>: In function 'int main()':
<source>:8:50: error: constant not recomputed when 'ADDR_EXPR' changed
    8 | int main() { printf("%s\n", HelloWorld.c_str()); }
      |                                                  ^
_3 = &HelloWorld.D.38876._M_local_buf;
during GIMPLE pass: einline
<source>:8:50: internal compiler error: verify_gimple failed
0x267adac internal_error(char const*, ...)
        ???:0
0x13e317e verify_gimple_in_cfg(function*, bool, bool)
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1

= - = - = - = - = - = - = - = - = - = - = - = - = - = - = - =

I don't have access to the gcc executable causing this problem, and
-freport-bug doesn't work from godbolt, so I can't give you the preprocessed
input.

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

* [Bug middle-end/114913] "verify_gimple failed" due to addition of two constexpr strings
  2024-05-01 21:02 [Bug c++/114913] New: "verify_gimple failed" due to addition of two constexpr strings jorg.brown at gmail dot com
@ 2024-05-01 21:11 ` pinskia at gcc dot gnu.org
  2024-05-01 21:18 ` mpolacek at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-05-01 21:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Reducing, note this ICEs only with checking enable and not release checking ...

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

* [Bug middle-end/114913] "verify_gimple failed" due to addition of two constexpr strings
  2024-05-01 21:02 [Bug c++/114913] New: "verify_gimple failed" due to addition of two constexpr strings jorg.brown at gmail dot com
  2024-05-01 21:11 ` [Bug middle-end/114913] " pinskia at gcc dot gnu.org
@ 2024-05-01 21:18 ` mpolacek at gcc dot gnu.org
  2024-05-01 22:24 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-05-01 21:18 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2024-05-01
     Ever confirmed|0                           |1

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

* [Bug middle-end/114913] "verify_gimple failed" due to addition of two constexpr strings
  2024-05-01 21:02 [Bug c++/114913] New: "verify_gimple failed" due to addition of two constexpr strings jorg.brown at gmail dot com
  2024-05-01 21:11 ` [Bug middle-end/114913] " pinskia at gcc dot gnu.org
  2024-05-01 21:18 ` mpolacek at gcc dot gnu.org
@ 2024-05-01 22:24 ` pinskia at gcc dot gnu.org
  2024-05-01 22:29 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-05-01 22:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |13.2.0

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Reduced testcase:
```
struct strt {
    char *_M_dataplus;
    char _M_local_buf[1];
    constexpr strt() noexcept : _M_dataplus(_M_local_buf) {}
    constexpr strt(const strt &__str)  : _M_dataplus(_M_local_buf) {}
};
constexpr  strt  f() {
    return {};
}
constexpr strt HelloWorld = f();
const char *a() { return HelloWorld._M_dataplus; }
```

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

* [Bug middle-end/114913] "verify_gimple failed" due to addition of two constexpr strings
  2024-05-01 21:02 [Bug c++/114913] New: "verify_gimple failed" due to addition of two constexpr strings jorg.brown at gmail dot com
                   ` (2 preceding siblings ...)
  2024-05-01 22:24 ` pinskia at gcc dot gnu.org
@ 2024-05-01 22:29 ` pinskia at gcc dot gnu.org
  2024-05-01 22:55 ` jorg.brown at gmail dot com
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-05-01 22:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
here is a C++11 testcase:
```
  struct strt {
    char *_M_dataplus;
    char _M_local_buf=0;
    constexpr strt()
      : _M_dataplus(&_M_local_buf) {}
    constexpr strt(const strt &__str)
      : _M_dataplus(&_M_local_buf) {}
  };
  constexpr  strt
  f() {
    return {};
  }
constexpr strt HelloWorld = f();
const char *a() { return HelloWorld._M_dataplus; }
```

it was rejected before GCC 10 with the following error message:
```
<source>:13:31: error: 'strt{(&<anonymous>.strt::_M_local_buf), '\000'}' is not
a constant expression
   13 | constexpr strt HelloWorld = f();
      |                               ^

```

Maybe that will give an hint where the issue is ...

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

* [Bug middle-end/114913] "verify_gimple failed" due to addition of two constexpr strings
  2024-05-01 21:02 [Bug c++/114913] New: "verify_gimple failed" due to addition of two constexpr strings jorg.brown at gmail dot com
                   ` (3 preceding siblings ...)
  2024-05-01 22:29 ` pinskia at gcc dot gnu.org
@ 2024-05-01 22:55 ` jorg.brown at gmail dot com
  2024-05-01 23:00 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jorg.brown at gmail dot com @ 2024-05-01 22:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jorg Brown <jorg.brown at gmail dot com> ---
Oddly, if I move the reference to HelloWorld into a separate routine, it works
(you can comment out a() and ba() returns what it should, on gcc 15.0)

struct strt {
  const char *ptr = &data;
  char data = '\0';

  constexpr strt() {}
  constexpr strt(const strt &__str) {}
};
constexpr strt f() { return {}; }
constexpr strt HelloWorld = f();

// This works fine...
const strt &b() { return HelloWorld; }
const char *ba() { return b().ptr; }

// This causes the verify_gimple failure, on gcc 15
const char *a() { return HelloWorld.ptr; }

= - = - = - = - = - = - =

Also odd is that the above code (including a()) works fine on gcc 10.1 through
13.2.  As seen https://godbolt.org/z/z3qnosG37

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

* [Bug middle-end/114913] "verify_gimple failed" due to addition of two constexpr strings
  2024-05-01 21:02 [Bug c++/114913] New: "verify_gimple failed" due to addition of two constexpr strings jorg.brown at gmail dot com
                   ` (4 preceding siblings ...)
  2024-05-01 22:55 ` jorg.brown at gmail dot com
@ 2024-05-01 23:00 ` pinskia at gcc dot gnu.org
  2024-05-02 11:28 ` [Bug c++/114913] " rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-05-01 23:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jorg Brown from comment #4) 
> Also odd is that the above code (including a()) works fine on gcc 10.1
> through 13.2.  As seen https://godbolt.org/z/z3qnosG37

This is not really odd since it does fail with those compilers with -fchecking
(which is the default for the GCC trunk development). It also works with the
trunk (in this case) with -fno-checking .  Basically GCC has some internal
checks to make sure things internally are consistent but they are failing in
this case and you can turn them off/on at compile time.

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

* [Bug c++/114913] "verify_gimple failed" due to addition of two constexpr strings
  2024-05-01 21:02 [Bug c++/114913] New: "verify_gimple failed" due to addition of two constexpr strings jorg.brown at gmail dot com
                   ` (5 preceding siblings ...)
  2024-05-01 23:00 ` pinskia at gcc dot gnu.org
@ 2024-05-02 11:28 ` rguenth at gcc dot gnu.org
  2024-05-02 14:13 ` ppalka at gcc dot gnu.org
  2024-05-02 15:21 ` ppalka at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-02 11:28 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|middle-end                  |c++

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
#4  0x00000000016da304 in fold_ctor_reference (
    type=<pointer_type 0x7ffff70417e0>, ctor=<addr_expr 0x7ffff71bfe80>, 
    poly_offset=..., poly_size=..., 
    from_decl=<var_decl 0x7ffff71ba750 HelloWorld>, suboff=0x7fffffffcbb8)
    at /space/rguenther/src/gcc/gcc/gimple-fold.cc:8236
8236        return canonicalize_constructor_val (unshare_expr (ctor),
from_decl);

'ctor' is the ADDR_EXPR that doesn't have TREE_CONSTANT set correctly.  The
tree is probably mangled after the ADDR_EXPR is built.  This looks like a
bug in the C++ frontend to me.

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

* [Bug c++/114913] "verify_gimple failed" due to addition of two constexpr strings
  2024-05-01 21:02 [Bug c++/114913] New: "verify_gimple failed" due to addition of two constexpr strings jorg.brown at gmail dot com
                   ` (6 preceding siblings ...)
  2024-05-02 11:28 ` [Bug c++/114913] " rguenth at gcc dot gnu.org
@ 2024-05-02 14:13 ` ppalka at gcc dot gnu.org
  2024-05-02 15:21 ` ppalka at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-05-02 14:13 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=110802
                 CC|                            |ppalka at gcc dot gnu.org

--- Comment #7 from Patrick Palka <ppalka at gcc dot gnu.org> ---
PR110802

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

* [Bug c++/114913] "verify_gimple failed" due to addition of two constexpr strings
  2024-05-01 21:02 [Bug c++/114913] New: "verify_gimple failed" due to addition of two constexpr strings jorg.brown at gmail dot com
                   ` (7 preceding siblings ...)
  2024-05-02 14:13 ` ppalka at gcc dot gnu.org
@ 2024-05-02 15:21 ` ppalka at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-05-02 15:21 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|https://gcc.gnu.org/bugzill |https://gcc.gnu.org/bugzill
                   |a/show_bug.cgi?id=110802    |a/show_bug.cgi?id=110822

--- Comment #8 from Patrick Palka <ppalka at gcc dot gnu.org> ---
PR110822 rather seems closely related if not a dup.

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

end of thread, other threads:[~2024-05-02 15:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-01 21:02 [Bug c++/114913] New: "verify_gimple failed" due to addition of two constexpr strings jorg.brown at gmail dot com
2024-05-01 21:11 ` [Bug middle-end/114913] " pinskia at gcc dot gnu.org
2024-05-01 21:18 ` mpolacek at gcc dot gnu.org
2024-05-01 22:24 ` pinskia at gcc dot gnu.org
2024-05-01 22:29 ` pinskia at gcc dot gnu.org
2024-05-01 22:55 ` jorg.brown at gmail dot com
2024-05-01 23:00 ` pinskia at gcc dot gnu.org
2024-05-02 11:28 ` [Bug c++/114913] " rguenth at gcc dot gnu.org
2024-05-02 14:13 ` ppalka at gcc dot gnu.org
2024-05-02 15:21 ` ppalka 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).