[Bug c++/64527] New: Constructor for empty struct not called in some situations

gcc at swtaarrs dot com gcc-bugzilla@gcc.gnu.org
Wed Jan 7 19:21:00 GMT 2015


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

            Bug ID: 64527
           Summary: Constructor for empty struct not called in some
                    situations
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc at swtaarrs dot com

Created attachment 34396
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34396&action=edit
c++ code exposing the bug

Build ctor.cpp with the following command:

> g++ -std=c++11 -Os -S -o ctor.S ctor.cpp

The optimization level doesn't appear to affect the presence of the bug, I just
used -Os to keep the output more compact.

Expected results: The m() function in ctor.S should contain a call to A::A().

Actual results: m() does nothing but zero out accessor::x. I've found at least
three ways to perturb the bug out of existence which are documented in comments
in the file.

The bug is also present in gcc 4.8.1 (I haven't tried anything older).

Compiling with -Wextra reports "warning: missing initializer for member
‘accessor::a’ [-Wmissing-field-initializers]" but I believe this shouldn't
affect the ouput.


gcc build info:

Target: x86_64-unknown-linux-gnu
Configured with: ./configure --prefix=/home/matthew/gcc-4.9.0-prefix
Thread model: posix
gcc version 4.9.0 (GCC)


More information about the Gcc-bugs mailing list