[cfe-users] inconsistent compilation error inside constexpr if
Manu agarwal via cfe-users
cfe-users at lists.llvm.org
Mon Aug 17 21:55:20 PDT 2020
Hello,
In the below code the compiler throws "undeclared identifier" when the commented line is uncommented. Whereas the line just before compiles fine.
Regards,
Manu
typedef bool (* DummyFunc) ();
bool ExecDummy (DummyFunc fptr) {
if (fptr)
return fptr ();
return false;
}
constexpr unsigned int IsMyAppClient = 0;
constexpr bool CheckForTypeClient (unsigned int pAppType)
{
return ((pAppType & IsMyAppClient) != 0);
}
class MyAppTemplate
{
public:
template <unsigned int T>
static bool MyAppInit ();
};
template <unsigned int T>
bool
MyAppTemplate::MyAppInit ()
{
if constexpr (CheckForTypeClient(T)) {
return ClientMain (); // no error
//return ExecDummy(ClientMain); // error: use of undeclared identifier 'ClientMain'
}
return false;
}
int __cdecl
main (int pArgc, char* pArgv[])
{
constexpr int TVal = 3;
MyAppTemplate::MyAppInit<TVal> ();
return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20200818/16b4b054/attachment.html>
More information about the cfe-users
mailing list