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

polarlinda6 <polarlinda6 at 163 dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |polarlinda6 at 163 dot com

--- Comment #1 from polarlinda6 <polarlinda6 at 163 dot com> ---
I also encountered this problem. I still don't know why there is a warning
about using an uninitialized value.


```cpp
#include <vector>

using type = std::vector<int>;
auto create() -> type {
  return type{};
}

auto main() -> int { [[maybe_unused]] auto v = create(); }

```

error msg:
<source>: In function 'type create()':
<source>:5:15: warning: use of uninitialized value '<unknown>' [CWE-457]
[-Wanalyzer-use-of-uninitialized-value]
    5 |   return type{};
      |               ^
  'type create()': events 1-3
    4 | auto create() -> type {
      | ^~~~
      | |
      | (1) region created on stack here
      | (2) capacity: 8 bytes
    5 |   return type{};
      |               ~
      |               |
      |               (3) ⚠️  use of uninitialized value '<unknown>' here
<source>:5:15: warning: use of uninitialized value '<unknown>' [CWE-457]
[-Wanalyzer-use-of-uninitialized-value]
    5 |   return type{};
      |               ^
  'int main()': events 1-2
    │
    │    8 | auto main() -> int { [[maybe_unused]] auto v = create(); }
    │      |      ^~~~                                             ~
    │      |      |                                                |
    │      |      (1) entry to 'main'                              (2) calling
'create' from 'main'
    │
    └──> 'type create()': events 3-6
           │
           │    4 | auto create() -> type {
           │      | ~~~~ ^~~~~~
           │      | |    |
           │      | |    (3) entry to 'create'
           │      | (4) region created on stack here
           │      | (5) capacity: 8 bytes
           │    5 |   return type{};
           │      |               ~
           │      |               |
           │      |               (6) ⚠️  use of uninitialized value '<unknown>'
here
           │
Compiler returned: 0

Additional Information:
Version: gcc 14.2 
compilation parameters; -std=c++20 -fanalyzer
Link: https://godbolt.org/z/sddcPK6Gr

PS: The code compiles successfully on msvc and clang.

Reply via email to