https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88175
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |manu at gcc dot gnu.org --- Comment #16 from Manuel López-Ibáñez <manu at gcc dot gnu.org> --- Reduced testcase for "-Wall -O1" (with -O2 the copy is now elided and we hit missing warning bugs) struct string { char *data; string() : data(0) {}; string(const string &x) : data(x.data) {}; }; typedef struct info { int registered; string dummy; } info_t; void test(info_t temp) { info_t copy; temp = copy; __builtin_printf("%d\n", copy.registered); } int main() { info_t temp; test(temp); } (In reply to Jonny Grant from comment #15) > Does the implicitly created copy-constructor get saved to a file at all? Or > can it be saved to a file like -save-temps does? No, it doesn't. It is not generated as C++ code. (In reply to Jonny Grant from comment #13) > Where there is an implicit copy constructor, it shows the wrong file, and > wrong function. It is not the wrong function, it is where tem.info()::registered is declared. This is what happens when there is no location for the use. No location happens here because the unintialized use happens within the implicit copy constructor and there is source code to show for that. https://godbolt.org/z/BPyIMe [./example.cpp:7:16] # .MEM_6 = VDEF <.MEM_4(D)> [./example.cpp:7:16] *this_5(D) ={v} {CLOBBER}; [./example.cpp:7:16] # VUSE <.MEM_6> _1 = _7(D)->registeredD.2353; [./example.cpp:7:16] # .MEM_8 = VDEF <.MEM_6> [./example.cpp:7:16] this_5(D)->registeredD.2353 = _1; The above is what GCC sees at the time of warning. (In reply to Jonny Grant from comment #14) > Wondering, if there is an implicitly created copy-constructor, can the > warning clarify that? Perhaps there is some attribute or flag set so later > code can know it was implicitly created? Probably yes. Even if the info is lost, it is easy to check that the location of the declaration of the copy-constructor is exactly the same as the location of the class, indicating that it was implicitly created. More useful would be to not warn within the implicit constructor but somehow pass the uninitialized info back to the caller and warn there. Warning within artificial code is mostly useless for users.