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

            Bug ID: 117501
           Summary: Consteval costructor does not initialize the variable
           Product: gcc
           Version: 14.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: intkecsk at yandex dot ru
  Target Milestone: ---

See: https://godbolt.org/z/9jvYTfYE4

```
struct QQQ {
    consteval QQQ(std::string_view d): data(d) {}
    std::string_view data;
};

void sink(const QQQ&);

void f() {
    QQQ q("dogsdogsdogs");
    sink(q);
}
```

This code is accepted with warnings

```
<source>: In function 'void f()':
<source>:13:25: warning: statement with no effect [-Wunused-value]
   13 |     QQQ q("dogsdogsdogs");
      |                         ^
<source>:14:9: warning: 'q' may be used uninitialized [-Wmaybe-uninitialized]
   14 |     sink(q);
      |     ~~~~^~~
<source>:10:6: note: by argument 1 of type 'const QQQ&' to 'void sink(const
QQQ&)' declared here
   10 | void sink(const QQQ&);
      |      ^~~~
<source>:13:9: note: 'q' declared here
   13 |     QQQ q("dogsdogsdogs");
      |      
```

And no code is generated for the initialization fo variable `q`

GCC 13 and Clang 19 accept this code with no warnings and the correct
initialization code is generated.

Reply via email to