[Bug c++/49372] Temporaries evaluated for arguments of a default constructors of array elements not destructed properly (?)

2023-05-08 Thread ppalka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49372

Patrick Palka  changed:

   What|Removed |Added

 CC||ppalka at gcc dot gnu.org
   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=92385
   Target Milestone|--- |12.0

--- Comment #6 from Patrick Palka  ---
It seems this is fixed for GCC 12+ by r12-6326-ge948436eab818c.

[Bug c++/49372] Temporaries evaluated for arguments of a default constructors of array elements not destructed properly (?)

2012-12-10 Thread ktietz at gcc dot gnu.org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49372



Kai Tietz ktietz at gcc dot gnu.org changed:



   What|Removed |Added



 Status|UNCONFIRMED |RESOLVED

 CC||ktietz at gcc dot gnu.org

 Resolution||INVALID



--- Comment #2 from Kai Tietz ktietz at gcc dot gnu.org 2012-12-10 11:06:49 
UTC ---

This testcase seems to produce for trunk, 4.7, and 4.6 the output CCDD, which

is proper as constructor of B is called by the array-constructor.

Btw you will need option -std=c++11 on trunk to get this test compile without

issues.


[Bug c++/49372] Temporaries evaluated for arguments of a default constructors of array elements not destructed properly (?)

2012-12-10 Thread redi at gcc dot gnu.org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49372



--- Comment #3 from Jonathan Wakely redi at gcc dot gnu.org 2012-12-10 
13:14:56 UTC ---

Kai, I don't think anyone disputes that B's constructor is called, the question

is why 12.2/4 doesn't apply.


[Bug c++/49372] Temporaries evaluated for arguments of a default constructors of array elements not destructed properly (?)

2012-12-10 Thread ktietz at gcc dot gnu.org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49372



Kai Tietz ktietz at gcc dot gnu.org changed:



   What|Removed |Added



 Status|RESOLVED|NEW

   Last reconfirmed||2012-12-10

 Resolution|INVALID |

 Ever Confirmed|0   |1



--- Comment #4 from Kai Tietz ktietz at gcc dot gnu.org 2012-12-10 13:42:30 
UTC ---

(In reply to comment #3)

 Kai, I don't think anyone disputes that B's constructor is called, the 
 question

 is why 12.2/4 doesn't apply.



Well, we have here 5.2.2 which says A function call is a postfix expression

followed by parentheses containing a possibly empty, comma-separated list of

expressions which constitute the arguments to the function.



But we don't have here an explicit function-call.  And an implicit call is not

an expression, hence, not a part of any full expression, and so we don't have a

sequence-point.  Not sure if specification intended it differently, but by its

current wording I would assume that current implementation is right.



But indeed 12.4 seems to be violated here.  There are two contexts in which

temporaries are destroyed at a different point than the end of the

fullexpression.

The first context is when a default constructor is called to initialize an

element of an array. If the constructor has one or more default arguments, the

destruction of every temporary created in a default argument expression is

sequenced before the construction of the next array element, if any.



So there is an antagonism in spec.  I will reopen it.  sorry, didn't read about

12.4


[Bug c++/49372] Temporaries evaluated for arguments of a default constructors of array elements not destructed properly (?)

2012-12-10 Thread schaub.johannes at googlemail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49372



--- Comment #5 from Johannes Schaub schaub.johannes at googlemail dot com 
2012-12-10 16:42:59 UTC ---

(In reply to comment #4)

 (In reply to comment #3)

  Kai, I don't think anyone disputes that B's constructor is called, the 
  question

  is why 12.2/4 doesn't apply.

 

 Well, we have here 5.2.2 which says A function call is a postfix expression

 followed by parentheses containing a possibly empty, comma-separated list of

 expressions which constitute the arguments to the function.

 

 But we don't have here an explicit function-call.  And an implicit call is not

 an expression, hence, not a part of any full expression, and so we don't have 
 a

 sequence-point.  Not sure if specification intended it differently, but by its

 current wording I would assume that current implementation is right.

 



See 1.9p10. The implicit function call is considered to be an expression.


[Bug c++/49372] Temporaries evaluated for arguments of a default constructors of array elements not destructed properly (?)

2011-06-11 Thread schaub.johannes at googlemail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49372

--- Comment #1 from Johannes Schaub schaub.johannes at googlemail dot com 
2011-06-11 13:46:46 UTC ---
To elaborate on it, I have the following weird behavior:

- GCC4.6 outputs nothing for the program (on my linux machine). That seems
definitely wrong in any case.
- GCC4.7 4.7.0 20110517 (experimental), using a mingw nightly build,
generates an executable that crashes when running:

[js@HOST2 cpp]$ ~/w64/bin/i686-w64-mingw32-g++ -std=c++0x -O1 -o a.exe
main1.cpp
[js@HOST2 cpp]$ wine ./a.exe
Cwine: Unhandled page fault on read access to 0x at address (nil)
(thread 0025), starting debugger...

- The same GCC4.7 when using -O2 does not crash and print CCDD:

[js@HOST2 cpp]$ ~/w64/bin/i686-w64-mingw32-g++ -std=c++0x -O2 -o a.exe
main1.cpp
[js@HOST2 cpp]$ wine ./a.exe
fixme:ntoskrnl:KeInitializeSpinLock stub: 0x5477a4
C
C
D
D

I don't know precisely whether this is a problem with wine or a temporary
problem with that nightly build of GCC I was using. My apologies if GCC trunk
works differently!