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

            Bug ID: 80649
           Summary: value-initialization rather than
                    default-initialization at some optimization levels
           Product: gcc
           Version: 6.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: john.duncan at oracle dot com
                CC: webrown.cpp at gmail dot com
  Target Milestone: ---
                CC: webrown.cpp at gmail dot com

This problem concerns a placement-new statement within a loop:

    new (ptr.p) TestRecord;

In this case "new TestRecord" without any parentheses or braces should perform
default-initialization. My experience with gcc 6.3 shows default-initialization
at some -O levels, but apparent value-initialization at other levels. In the
example submitted here in the bug report, the problem appears at -O1 but not at
-O2. In the actual large codebase where I first observed the problem, it was
seen at -O2 but not at -O1.

Reply via email to