Issue 120197
Summary Cannot compare std::string's in if constexpr
Labels new issue
Assignees
Reporter Fedr
    This program
```c++
#include <string>

struct A {
    static constexpr std::string name() { return "a"; }  
};

template<class T>
bool f( T && ) {
    if constexpr ( T::name() == "a" )
        return true;
    else
        return false;
}

int main() {
    return f( A{} );
}
```
is accepted by GCC and MSVC, but Clang complains:
```
error: constexpr if condition is not a constant _expression_
    9 |     if constexpr ( T::name() == "a" )
      | ^~~~~~~~~~~~~~~~
```
Online demo: https://gcc.godbolt.org/z/o3nMx3zWj

Original discussion: https://stackoverflow.com/q/79283228/7325599

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

Reply via email to