[llvm-bugs] [Bug 38673] New: C++ constexpr inheriting constructor

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 22 22:23:54 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=38673

            Bug ID: 38673
           Summary: C++ constexpr inheriting constructor
           Product: clang
           Version: 6.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ankur.dedev at tuta.io
                CC: llvm-bugs at lists.llvm.org

The code below fails to compile in Clang 6.0.1, the following Stack Overflow
answer https://stackoverflow.com/a/51854172/9363849 suggests that it might not
be the intended behavior.


// A struct named Foo.
struct Foo
{
  // Data member of type 'int'.
  int val;

  // Default constructor (constexpr).
  constexpr Foo() noexcept : val(0) {}
};

// A struct named Bar.
struct Bar : Foo
{
  // Make use of the constructors declared in Foo.
  using Foo::Foo;

  // A constructor taking an object of type Foo.
  // COMMENTING THIS CONSTRUCTOR SOLVE THE COMPILATION ISSUE.
  constexpr Bar(Foo const obj) noexcept : Foo(obj) {}
};


// A struct named Test.
struct Test
{
  // Data member of type 'Bar'.
  Bar bar;

  // A defaulted default constructor.
  constexpr Test() noexcept = default;
};


// Main function.
int main() { return 0; }

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180823/9d95ac52/attachment.html>


More information about the llvm-bugs mailing list