https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82552

            Bug ID: 82552
           Summary: No warning when using uninitialized values in
                    initializer list
           Product: gcc
           Version: 7.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: s-beyer at gmx dot net
  Target Milestone: ---

Hi,

the following code example is pretty harmless but the underlying issue
took me quite some time to debug in real code (where the constructors
are really doing stuff):

----8<----
struct bar {
        bar() {}
        bar(bar&) {}
};

class foo {
        bar first;
        bar second;

public:
        foo() : first(second) {}
};
---->8----

The interesting thing is the foo constructor.
It initializes "first" with "second", but the initializer list
is going in order of the attributes, so "first" is initialized
before "second" is.

I'd expect either an -Wreorder warning ("second" will be initialized after
"first") or an -Wuninitialized ("second" will be used uninitialized) warning
(which is what clang++ does).

I tested this with g++ 4.9.3, 5.4.1, 6.4.0, and 7.2.0. None of it raised
alarm :(

Thanks.

Reply via email to