Skip to content

constexpr constructors can't initialize constexpr variables #11529

@llvmbot

Description

@llvmbot
Bugzilla Link 11157
Resolution DUPLICATE
Resolved on Oct 17, 2011 16:31
Version trunk
OS Linux
Attachments demo source code
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@efriedma-quic,@zygoloid

Extended Description

With the attached source file, I get the following error message:

clang++ -std=c++11 -c constexpr.cc
constexpr.cc:7:13: error: constexpr variable 'a' must be initialized by a constant expression
constexpr X a(2);
^~~~
1 error generated.

The second variable "b" which calls the default constructor gets initialized correctly, but the "constexpr" constructor cannot be called to initialize the variable "a".

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++11duplicateResolved as duplicate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions