Bug 61581 - [C++11] Bogus error: uninitialized const member
Summary: [C++11] Bogus error: uninitialized const member
Status: RESOLVED DUPLICATE of bug 49132
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-21 16:53 UTC by Paul Pluzhnikov
Modified: 2014-06-26 17:00 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Pluzhnikov 2014-06-21 16:53:44 UTC
Google ref: b/15789654

Fails with current trunk, and all older versions I've tried.

g++ -c t.cc -std=c++11
t.cc: In function 'void Bar()':
t.cc:9:11: error: uninitialized const member 'Foo::b'
   Fn( {1} );
           ^

/// -- cut ---
struct Foo {
  long a;
  const long b;
};

void Fn(const Foo&);

void Bar() {
  Fn( {1} );
}
/// -- cut ---

Removing 'const' and examining assembly shows that GCC *does* initialize 'b' to 0 (as it should).
Comment 1 Paolo Carlini 2014-06-26 17:00:37 UTC
Dup.

*** This bug has been marked as a duplicate of bug 49132 ***