You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"May be used uninitialized" warning from g++ 15.2.1 with -O2 #629
First of all, thanks for the library, it is very useful!
I included the library sources (reflectcpp.cpp, reflectcpp_json.cpp and yyjson.c) to my sources and tried building them unoptimized and optimized. Build succeeds without -O flag and with -O1, but some warnings appear with -O2.
>::_Vector_impl_data::_M_end_of_storage’ may be used uninitialized [-Werror=maybe-uninitialized]
113 | _M_end_of_storage(__x._M_end_of_storage)
@Kirisummer , this does not even appear to be from our library, this piece of code is from the C++ standard library. I also don't know how exactly Object<...>:i_ could be used uninitialized.
The warnings happen on lines with creation of Generic from Array or Null, and Generic is immediately passed to vector::push_back. Some warnings say that is used before initialization. I suspect this might be the case where a temporary value is optimized out.
I will try to create a variable which is then moved inside the vector, or to use emplace_back instead of push_back to avoid creating a temporary value at all.
Activity
liuzicheng1987 commentedon Mar 8, 2026
@Kirisummer , this does not even appear to be from our library, this piece of code is from the C++ standard library. I also don't know how exactly Object<...>:i_ could be used uninitialized.
liuzicheng1987 commentedon Mar 8, 2026
@Kirisummer , this is very weird, I'll have to take a closer look. Thanks for reporting.
Kirisummer commentedon Mar 8, 2026
The warnings happen on lines with creation of Generic from Array or Null, and Generic is immediately passed to vector::push_back. Some warnings say that is used before initialization. I suspect this might be the case where a temporary value is optimized out.
I will try to create a variable which is then moved inside the vector, or to use emplace_back instead of push_back to avoid creating a temporary value at all.
[Bugfix] Something to do with temporaries