Repository navigation
Temporary destroyed before aggregate initialization completes #294
71iq
started this conversation in
Issue Triage - Compilation
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Version
Compiler: 7.0, commit
43e10b90fc83ed2a436fb79b241be8dbf3dc6846Platform: Linux x86_64 (LP64)
Reference/compiler for generated C: GCC 13.3.0
Preset:
linux-gcc-debug, withEDG_CPFE_USE_ASAN=OFFRelevant configuration:
Code to reproduce
Compiler options:
Behavior
The temporary
Temp{}, bound to the constructor's reference parameter, should remain alive until the initialization ofpcompletes. Both assertions should pass.The reference program compiled with GCC exits with status 0. Compilation through the C-generating backend succeeds, but the translated program aborts inside
bar():The generated C calls
Temp::~Temp()before callingbar(), sogoneis already true while initializingp.b.C++20 [class.temporary]/4 and /6.9 require destruction at the end of the containing full-expression. Sequencing the aggregate's elements does not create a separate destruction boundary for each initializer.
References: class.temporary, intro.execution, dcl.init.aggr.
The same destructor placement occurs with exceptions enabled;
--no_exceptionslets this small translated program link without the C++ support runtime.The attachment contains the full
--dump_configurationoutput and self-contained reproduction inputs.Source, generated C, results, and full configuration
Reporting acknowledgements
I acknowledge that:
LICENSE.txtfile in my.zipor.tar.gzupload. If I included aLICENSE.txtfile, any tests created using the reproducing source code will be governed by the terms of the license I provided instead.All reactions