Issue 129986
Summary Constexpr template member function call is not taken as a constant _expression_
Labels new issue
Assignees
Reporter WorldRobertProject
        class X
    {
    public:
 constexpr X()
        {
            Foo(1);
        }
    
 template <typename T>
        constexpr void Foo(T value)
        {
 }
    };
    
    constexpr X x;

The above code produces the following compilation error:

    error: constexpr variable 'x' must be initialized by a constant _expression_
    | constexpr X x;
    |             ^
 note: undefined function 'Foo<int>' cannot be used in a constant _expression_
 |         Foo(1);
    |         ^
    note: in call to 'X()'
    | constexpr X x;
    |             ^
    note: declared here
    | constexpr void Foo(T value)
    |                    ^

When Foo is a global function, no error occurs.

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to