public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100838] New: -fno-elide-constructors for C++14 missing required destructor call
@ 2021-05-30 20:37 kirshamir at gmail dot com
2021-05-30 20:40 ` [Bug c++/100838] " kirshamir at gmail dot com
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: kirshamir at gmail dot com @ 2021-05-30 20:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100838
Bug ID: 100838
Summary: -fno-elide-constructors for C++14 missing required
destructor call
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: kirshamir at gmail dot com
Target Milestone: ---
Code: https://godbolt.org/z/jKnKTds7s
#include <iostream>
class MyString {
public:
MyString(const char* s = "") {
std::cout << "ctor" << std::endl;
}
~MyString() {
std::cout << "dtor" << std::endl;
}
MyString(const MyString& s) {
std::cout << "copy ctor" << std::endl;
}
MyString& operator=(const MyString& s) {
std::cout << "operator=" << std::endl;
return *this;
}
};
int main() {
MyString s1 = "Hello";
std::cout << __LINE__ << std::endl;
}
---------------
When compiled with:
-std=c++14 -fno-elide-constructors
Output:
ctor
copy ctor
22
dtor
Expected output:
ctor
copy ctor
dtor
22
dtor
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/100838] -fno-elide-constructors for C++14 missing required destructor call
2021-05-30 20:37 [Bug c++/100838] New: -fno-elide-constructors for C++14 missing required destructor call kirshamir at gmail dot com
@ 2021-05-30 20:40 ` kirshamir at gmail dot com
2021-05-31 9:08 ` [Bug c++/100838] [11/12 Regression] -fno-elide-constructors for C++14 missing required destructor call since r11-5872-g4eb28483004f8291 marxin at gcc dot gnu.org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: kirshamir at gmail dot com @ 2021-05-30 20:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100838
--- Comment #1 from Amir Kirsh <kirshamir at gmail dot com> ---
This main:
int main() {
MyString s1 = MyString{"Hello"}; // same also for rounded brackets
std::cout << __LINE__ << std::endl;
}
works as expected.
Output with C++14 and -fno-elide-constructors:
ctor
copy ctor
dtor
22
dtor
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/100838] [11/12 Regression] -fno-elide-constructors for C++14 missing required destructor call since r11-5872-g4eb28483004f8291
2021-05-30 20:37 [Bug c++/100838] New: -fno-elide-constructors for C++14 missing required destructor call kirshamir at gmail dot com
2021-05-30 20:40 ` [Bug c++/100838] " kirshamir at gmail dot com
@ 2021-05-31 9:08 ` marxin at gcc dot gnu.org
2021-05-31 14:49 ` jason at gcc dot gnu.org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-05-31 9:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100838
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu.org,
| |marxin at gcc dot gnu.org
Summary|-fno-elide-constructors for |[11/12 Regression]
|C++14 missing required |-fno-elide-constructors for
|destructor call |C++14 missing required
| |destructor call since
| |r11-5872-g4eb28483004f8291
Ever confirmed|0 |1
Last reconfirmed| |2021-05-31
Status|UNCONFIRMED |NEW
--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r11-5872-g4eb28483004f8291.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/100838] [11/12 Regression] -fno-elide-constructors for C++14 missing required destructor call since r11-5872-g4eb28483004f8291
2021-05-30 20:37 [Bug c++/100838] New: -fno-elide-constructors for C++14 missing required destructor call kirshamir at gmail dot com
2021-05-30 20:40 ` [Bug c++/100838] " kirshamir at gmail dot com
2021-05-31 9:08 ` [Bug c++/100838] [11/12 Regression] -fno-elide-constructors for C++14 missing required destructor call since r11-5872-g4eb28483004f8291 marxin at gcc dot gnu.org
@ 2021-05-31 14:49 ` jason at gcc dot gnu.org
2021-06-02 18:42 ` cvs-commit at gcc dot gnu.org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu.org @ 2021-05-31 14:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100838
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |jason at gcc dot gnu.org
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/100838] [11/12 Regression] -fno-elide-constructors for C++14 missing required destructor call since r11-5872-g4eb28483004f8291
2021-05-30 20:37 [Bug c++/100838] New: -fno-elide-constructors for C++14 missing required destructor call kirshamir at gmail dot com
` (2 preceding siblings ...)
2021-05-31 14:49 ` jason at gcc dot gnu.org
@ 2021-06-02 18:42 ` cvs-commit at gcc dot gnu.org
2021-06-09 0:47 ` [Bug c++/100838] [11 " jason at gcc dot gnu.org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-06-02 18:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100838
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:
https://gcc.gnu.org/g:63d182b29306e582bfb151cf762820211ea1cc7e
commit r12-1165-g63d182b29306e582bfb151cf762820211ea1cc7e
Author: Jason Merrill <jason@redhat.com>
Date: Mon May 31 12:36:25 2021 -0400
c++: missing dtor with -fno-elide-constructors [PR100838]
tf_no_cleanup only applies to the outermost TARGET_EXPR, and we already
clear it for nested calls in build_over_call, but in this case both
constructor calls came from convert_like, so we need to clear it in the
recursive call as well. This revealed that we were adding an extra
ck_rvalue in direct-initialization cases where it was wrong.
PR c++/100838
gcc/cp/ChangeLog:
* call.c (convert_like_internal): Clear tf_no_cleanup when
recursing.
(build_user_type_conversion_1): Only add ck_rvalue if
LOOKUP_ONLYCONVERTING.
gcc/testsuite/ChangeLog:
* g++.dg/init/no-elide2.C: New test.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/100838] [11 Regression] -fno-elide-constructors for C++14 missing required destructor call since r11-5872-g4eb28483004f8291
2021-05-30 20:37 [Bug c++/100838] New: -fno-elide-constructors for C++14 missing required destructor call kirshamir at gmail dot com
` (3 preceding siblings ...)
2021-06-02 18:42 ` cvs-commit at gcc dot gnu.org
@ 2021-06-09 0:47 ` jason at gcc dot gnu.org
2021-07-06 6:46 ` rguenth at gcc dot gnu.org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu.org @ 2021-06-09 0:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100838
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[11/12 Regression] |[11 Regression]
|-fno-elide-constructors for |-fno-elide-constructors for
|C++14 missing required |C++14 missing required
|destructor call since |destructor call since
|r11-5872-g4eb28483004f8291 |r11-5872-g4eb28483004f8291
--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 12 so far.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/100838] [11 Regression] -fno-elide-constructors for C++14 missing required destructor call since r11-5872-g4eb28483004f8291
2021-05-30 20:37 [Bug c++/100838] New: -fno-elide-constructors for C++14 missing required destructor call kirshamir at gmail dot com
` (4 preceding siblings ...)
2021-06-09 0:47 ` [Bug c++/100838] [11 " jason at gcc dot gnu.org
@ 2021-07-06 6:46 ` rguenth at gcc dot gnu.org
2021-07-09 20:14 ` cvs-commit at gcc dot gnu.org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-06 6:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100838
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |11.2
Priority|P3 |P2
Known to work| |12.0
Known to fail| |11.1.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/100838] [11 Regression] -fno-elide-constructors for C++14 missing required destructor call since r11-5872-g4eb28483004f8291
2021-05-30 20:37 [Bug c++/100838] New: -fno-elide-constructors for C++14 missing required destructor call kirshamir at gmail dot com
` (5 preceding siblings ...)
2021-07-06 6:46 ` rguenth at gcc dot gnu.org
@ 2021-07-09 20:14 ` cvs-commit at gcc dot gnu.org
2021-07-09 20:15 ` jason at gcc dot gnu.org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-09 20:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100838
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:
https://gcc.gnu.org/g:5830fffacd05463c20b592bb6ed20e333d7d272b
commit r11-8715-g5830fffacd05463c20b592bb6ed20e333d7d272b
Author: Jason Merrill <jason@redhat.com>
Date: Mon May 31 12:36:25 2021 -0400
c++: missing dtor with -fno-elide-constructors [PR100838]
tf_no_cleanup only applies to the outermost TARGET_EXPR, and we already
clear it for nested calls in build_over_call, but in this case both
constructor calls came from convert_like, so we need to clear it in the
recursive call as well. This revealed that we were adding an extra
ck_rvalue in direct-initialization cases where it was wrong.
For GCC 11, limit the changes to -fno-elide-constructors.
PR c++/100838
gcc/cp/ChangeLog:
* call.c (convert_like_internal): Clear tf_no_cleanup when
recursing.
(build_user_type_conversion_1): Only add ck_rvalue if
LOOKUP_ONLYCONVERTING.
gcc/testsuite/ChangeLog:
* g++.dg/init/no-elide2.C: New test.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/100838] [11 Regression] -fno-elide-constructors for C++14 missing required destructor call since r11-5872-g4eb28483004f8291
2021-05-30 20:37 [Bug c++/100838] New: -fno-elide-constructors for C++14 missing required destructor call kirshamir at gmail dot com
` (6 preceding siblings ...)
2021-07-09 20:14 ` cvs-commit at gcc dot gnu.org
@ 2021-07-09 20:15 ` jason at gcc dot gnu.org
2022-04-14 0:22 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu.org @ 2021-07-09 20:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100838
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 11.2/12.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/100838] [11 Regression] -fno-elide-constructors for C++14 missing required destructor call since r11-5872-g4eb28483004f8291
2021-05-30 20:37 [Bug c++/100838] New: -fno-elide-constructors for C++14 missing required destructor call kirshamir at gmail dot com
` (7 preceding siblings ...)
2021-07-09 20:15 ` jason at gcc dot gnu.org
@ 2022-04-14 0:22 ` cvs-commit at gcc dot gnu.org
2022-05-12 20:14 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-14 0:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100838
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:
https://gcc.gnu.org/g:019d6d4149ee97d55ce9efe4e5e470d38130cdeb
commit r12-8149-g019d6d4149ee97d55ce9efe4e5e470d38130cdeb
Author: Jason Merrill <jason@redhat.com>
Date: Wed Apr 13 12:44:54 2022 -0400
c++: add test [PR105265]
This was fixed by r12-1165, but good to have a test that doesn't need
-fno-elide-constructors.
PR c++/105265
PR c++/100838
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/initlist-new6.C: New test.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/100838] [11 Regression] -fno-elide-constructors for C++14 missing required destructor call since r11-5872-g4eb28483004f8291
2021-05-30 20:37 [Bug c++/100838] New: -fno-elide-constructors for C++14 missing required destructor call kirshamir at gmail dot com
` (8 preceding siblings ...)
2022-04-14 0:22 ` cvs-commit at gcc dot gnu.org
@ 2022-05-12 20:14 ` cvs-commit at gcc dot gnu.org
2022-05-12 21:24 ` cvs-commit at gcc dot gnu.org
2022-05-13 18:24 ` cvs-commit at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-12 20:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100838
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:
https://gcc.gnu.org/g:728f97cf0431ff342beceea4f91afa1707133248
commit r11-9985-g728f97cf0431ff342beceea4f91afa1707133248
Author: Jason Merrill <jason@redhat.com>
Date: Wed Apr 13 20:18:33 2022 -0400
c++: temp cleanup in new [PR105265]
The patch for PR100838 in GCC 11 was limited to -fno-elide-constructors for
safety, but this testcase demonstrates that it's also needed without that
flag. So let's switch to the GCC 12 patch for PR100838.
PR c++/105265
PR c++/100838
gcc/cp/ChangeLog:
* call.c (build_user_type_conversion_1): Drop
flag_elide_constructors check.
(convert_like_internal): Likewise.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/initlist-new6.C: New test.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/100838] [11 Regression] -fno-elide-constructors for C++14 missing required destructor call since r11-5872-g4eb28483004f8291
2021-05-30 20:37 [Bug c++/100838] New: -fno-elide-constructors for C++14 missing required destructor call kirshamir at gmail dot com
` (9 preceding siblings ...)
2022-05-12 20:14 ` cvs-commit at gcc dot gnu.org
@ 2022-05-12 21:24 ` cvs-commit at gcc dot gnu.org
2022-05-13 18:24 ` cvs-commit at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-12 21:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100838
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:
https://gcc.gnu.org/g:67f742536cbb60d5f8b7bba2cac0a141191e29af
commit r10-10727-g67f742536cbb60d5f8b7bba2cac0a141191e29af
Author: Jason Merrill <jason@redhat.com>
Date: Mon May 31 12:36:25 2021 -0400
c++: missing dtor with -fno-elide-constructors [PR100838]
tf_no_cleanup only applies to the outermost TARGET_EXPR, and we already
clear it for nested calls in build_over_call, but in this case both
constructor calls came from convert_like, so we need to clear it in the
recursive call as well. This revealed that we were adding an extra
ck_rvalue in direct-initialization cases where it was wrong.
PR c++/100838
PR c++/105265
gcc/cp/ChangeLog:
* call.c (convert_like_internal): Clear tf_no_cleanup when
recursing.
(build_user_type_conversion_1): Only add ck_rvalue if
LOOKUP_ONLYCONVERTING.
gcc/testsuite/ChangeLog:
* g++.dg/init/no-elide2.C: New test.
* g++.dg/cpp0x/initlist-new6.C: New test.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/100838] [11 Regression] -fno-elide-constructors for C++14 missing required destructor call since r11-5872-g4eb28483004f8291
2021-05-30 20:37 [Bug c++/100838] New: -fno-elide-constructors for C++14 missing required destructor call kirshamir at gmail dot com
` (10 preceding siblings ...)
2022-05-12 21:24 ` cvs-commit at gcc dot gnu.org
@ 2022-05-13 18:24 ` cvs-commit at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-13 18:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100838
--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:
https://gcc.gnu.org/g:200d477d3cb1593dbaa7739c6270e0a7f6c564cf
commit r9-10178-g200d477d3cb1593dbaa7739c6270e0a7f6c564cf
Author: Jason Merrill <jason@redhat.com>
Date: Mon May 31 12:36:25 2021 -0400
c++: missing dtor with -fno-elide-constructors [PR100838]
tf_no_cleanup only applies to the outermost TARGET_EXPR, and we already
clear it for nested calls in build_over_call, but in this case both
constructor calls came from convert_like, so we need to clear it in the
recursive call as well. This revealed that we were adding an extra
ck_rvalue in direct-initialization cases where it was wrong.
PR c++/100838
PR c++/105265
gcc/cp/ChangeLog:
* call.c (convert_like_internal): Clear tf_no_cleanup when
recursing.
(build_user_type_conversion_1): Only add ck_rvalue if
LOOKUP_ONLYCONVERTING.
gcc/testsuite/ChangeLog:
* g++.dg/init/no-elide2.C: New test.
* g++.dg/cpp0x/initlist-new6.C: New test.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2022-05-13 18:24 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-30 20:37 [Bug c++/100838] New: -fno-elide-constructors for C++14 missing required destructor call kirshamir at gmail dot com
2021-05-30 20:40 ` [Bug c++/100838] " kirshamir at gmail dot com
2021-05-31 9:08 ` [Bug c++/100838] [11/12 Regression] -fno-elide-constructors for C++14 missing required destructor call since r11-5872-g4eb28483004f8291 marxin at gcc dot gnu.org
2021-05-31 14:49 ` jason at gcc dot gnu.org
2021-06-02 18:42 ` cvs-commit at gcc dot gnu.org
2021-06-09 0:47 ` [Bug c++/100838] [11 " jason at gcc dot gnu.org
2021-07-06 6:46 ` rguenth at gcc dot gnu.org
2021-07-09 20:14 ` cvs-commit at gcc dot gnu.org
2021-07-09 20:15 ` jason at gcc dot gnu.org
2022-04-14 0:22 ` cvs-commit at gcc dot gnu.org
2022-05-12 20:14 ` cvs-commit at gcc dot gnu.org
2022-05-12 21:24 ` cvs-commit at gcc dot gnu.org
2022-05-13 18:24 ` cvs-commit at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).