https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55203
mauro russo <ing.russomauro at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ing.russomauro at gmail dot com --- Comment #25 from mauro russo <ing.russomauro at gmail dot com> --- Hello, I was going to post a new potential bug (for gcc 14.2) and then found two exist: PR 60212 and this one, too. I will paste here below my intended message with the error description, but note that in my description a missing warning happens also for trivial type when the value-initialization is used. I wasn't sure whether to post this message here or in PR 60212. I found the case while studying differences about user-provided and non-user-provided explicitly-defaulted default constructors. In the following code: struct X{ X() = default; // int m; }; //X::X() = default; int main() { X x; return 0; } gcc raises a warning about unused variable x, but in the following other code (https://godbolt.org/z/36WKzbvP6) struct X{ X(); // = default; // int m; }; X::X() = default; int main() { X x; return 0; } no warning is issued. Well, in second case, the explictly-defaulted default constructor is user-provided, which also leads it not to be trivial (and, consequently, the type neither). However, in both cases, no initialization of any base or non-static data member is done, and nothing changes also if a data member "int m;" is added (with no default member initializer). I cannot figure out what motivation may lead to a different behaviour. In particular, if the opposite behaviour would have happened, I could have supposed the error to be related to the vacuous-initialization when non-user-provided (first case). Additionally, note that if 'x' is value-initialized ("X x{};"), then the warning disappears in both cases (trivial or non-trivial), regardless of adding or not an "int m;" data member, where the only theoretical difference (beyond the 'trivial' and consequent 'vacuous-initialization') is that no zero-initialization is performed as first step of the value-initialization (see https://eel.is/c++draft/dcl.init.general#9.1), before the default-initialization (that does nothing).