This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/85691] New: Faulty Class Member Default Initialization - No Warning or Error


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
*/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]