public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97128] New: Uninitialized members of base class wrongly allowed in constexpr constructor
@ 2020-09-21 1:10 feodor.alexeev+gcc at gmail dot com
2020-09-21 1:12 ` [Bug c++/97128] " feodor.alexeev+gcc at gmail dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: feodor.alexeev+gcc at gmail dot com @ 2020-09-21 1:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97128
Bug ID: 97128
Summary: Uninitialized members of base class wrongly allowed in
constexpr constructor
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: feodor.alexeev+gcc at gmail dot com
Target Milestone: ---
Given this code: (https://godbolt.org/z/qsaeM7)
struct Base {
int x;
};
struct Derived : Base {
constexpr Derived() { }
};
int main () {
constexpr Derived kDerived;
return kDerived.x;
}
g++ -std=c++17 -pedantic compiles the program that exits with code 0.
clang rejects it as I believe in c++17 for a constructor to be constexpr all
members must be initialized before execution enters the body of the
constructor.
I also believe that the program is invalid as of c++20 as all must be
initialized by the end of the constexpr constructor. Still g++ -std=c++2a
compiles it.
Note that if there was an uninitialized member of Derived itself, g++ would
generate an error as expected.
There is a similar bug filed where g++ wrongly allows uninitialized member of
anonymous struct inside a union member:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86581 . Not sure if this counts as
a duplicate.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/97128] Uninitialized members of base class wrongly allowed in constexpr constructor
2020-09-21 1:10 [Bug c++/97128] New: Uninitialized members of base class wrongly allowed in constexpr constructor feodor.alexeev+gcc at gmail dot com
@ 2020-09-21 1:12 ` feodor.alexeev+gcc at gmail dot com
2020-09-21 1:19 ` [Bug c++/97128] Uninitialized members of base class wrongly allowed in constexpr constructor in c++17 mode feodor.alexeev+gcc at gmail dot com
2021-04-15 0:30 ` msebor at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: feodor.alexeev+gcc at gmail dot com @ 2020-09-21 1:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97128
--- Comment #1 from Fedor Alekseev <feodor.alexeev+gcc at gmail dot com> ---
Sorry, the link in the initial comment led to a slightly less minimal example.
Here's a link to the code from the initial comment in CE:
https://godbolt.org/z/dWP1sh
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/97128] Uninitialized members of base class wrongly allowed in constexpr constructor in c++17 mode
2020-09-21 1:10 [Bug c++/97128] New: Uninitialized members of base class wrongly allowed in constexpr constructor feodor.alexeev+gcc at gmail dot com
2020-09-21 1:12 ` [Bug c++/97128] " feodor.alexeev+gcc at gmail dot com
@ 2020-09-21 1:19 ` feodor.alexeev+gcc at gmail dot com
2021-04-15 0:30 ` msebor at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: feodor.alexeev+gcc at gmail dot com @ 2020-09-21 1:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97128
--- Comment #2 from Fedor Alekseev <feodor.alexeev+gcc at gmail dot com> ---
Also my initial claim about c++20 was wrong, gcc 10+ generates the error when
provided with -std=c++2a switch.
Still there is a problem in c++17 mode.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/97128] Uninitialized members of base class wrongly allowed in constexpr constructor in c++17 mode
2020-09-21 1:10 [Bug c++/97128] New: Uninitialized members of base class wrongly allowed in constexpr constructor feodor.alexeev+gcc at gmail dot com
2020-09-21 1:12 ` [Bug c++/97128] " feodor.alexeev+gcc at gmail dot com
2020-09-21 1:19 ` [Bug c++/97128] Uninitialized members of base class wrongly allowed in constexpr constructor in c++17 mode feodor.alexeev+gcc at gmail dot com
@ 2021-04-15 0:30 ` msebor at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-04-15 0:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97128
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |msebor at gcc dot gnu.org
Status|UNCONFIRMED |NEW
Last reconfirmed| |2021-04-15
Ever confirmed|0 |1
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=99700
--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed. If it's a regression I can't tell when it happened. See also
pr99700 for a similar test case in C++ 20 mode.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-04-15 0:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-21 1:10 [Bug c++/97128] New: Uninitialized members of base class wrongly allowed in constexpr constructor feodor.alexeev+gcc at gmail dot com
2020-09-21 1:12 ` [Bug c++/97128] " feodor.alexeev+gcc at gmail dot com
2020-09-21 1:19 ` [Bug c++/97128] Uninitialized members of base class wrongly allowed in constexpr constructor in c++17 mode feodor.alexeev+gcc at gmail dot com
2021-04-15 0:30 ` msebor 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).