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

            Bug ID: 80829
           Summary: Use of constexpr constructors with base type
                    instantiation fails compilation
           Product: gcc
           Version: 7.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: aaron.wood at verizon dot com
  Target Milestone: ---

Created attachment 41389
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41389&action=edit
Small reproducer

GCC 7.1 fails to compile programs where a type extends another type, both types
have constexpr constructors, and instantiating is done like so: constexpr A a =
B(10);

This produces: error: 'B(10).B::<anonymous>' is not a constant expression
because it refers to an incompletely initialized variable
    constexpr A a = B(10);

The fix/workaround is to not use the base type: constexpr B b = B(10);

I've attached a small program that shows the A and B types I'm using here and
easily reproduces this issue on 7.1.

Reply via email to