[Bug c++/85691] New: Faulty Class Member Default Initialization - No Warning or Error
roger at rankedgaming dot com
gcc-bugzilla@gcc.gnu.org
Tue May 8 01:08:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85691
Bug ID: 85691
Summary: Faulty Class Member Default Initialization - No
Warning or Error
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: roger at rankedgaming dot com
Target Milestone: ---
/// Bug Report
struct test
{
int x = data;
int data;
test(int o) : data(o) { }
};
/// Potentially Related Issue
struct test2
{
int x;
int data;
test2(int o) : data(o), x(data) { }
};
/*
- Details -
There should be a warning/error for test and test2.
In test the default initialization of x relies on data, which is initialized
after x.
In test2 the constructor initialization list is out of order. Same result as
for test.
- Note -
clang displays a warning for both these cases, but neither gcc nor msvc do
*/
More information about the Gcc-bugs
mailing list