Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Parsing Error templated constexpr member variable

Mueller__Tobias
Beginner
1,411 Views

Description:

When intializing a static constexpr class member variable using a brace-enclosed expression, compilation fails with error "expected a ")"".

Affected Versions:

icpc (ICC) 19.1.0.166 20191121

Minimal example:

class Test
{
template< typename Foo >
static constexpr bool UseSMPAssign_v =  (true) ;
};

int main(int argc, char** argv)
{
    return 0;
}

 

Expected Result:

Minimal example compiles without errors

Actual Result:

Compilation Fails with

testmain2.cpp(4): error: expected a ")"
  static constexpr bool UseSMPAssign_v =  (true) ;
                                                 ^

compilation aborted for testmain2.cpp (code 2)

Other Compilers:

GCC 8.3 and 9.2 are compiling the example

Note:

Omitting the Braces fixes the issue, but syntactically there should be nothing wrong adding them.

0 Kudos
9 Replies
PrasanthD_intel
Moderator
1,414 Views

Hi,

We have also observed the error at our end. This seems to be a bug with the compiler.

Thanks for reporting. We will forward this issue to the respective engineering team.

 

Thanks 

Prasanth

0 Kudos
Viet_H_Intel
Moderator
1,414 Views

I have submitted this bug to our FrontEnd (CMPLRIL0-32644). In the meantime, can you remove the () as a workaround?

0 Kudos
Mueller__Tobias
Beginner
1,414 Views

Thank you for submitting the bug. Unfortunately, trying to implement the workaround, I found another one, which looks related, but prevents me from using templated static constexpr member variables for SFINAE (and therefore the blaze-library) with icpc.

It seems like any bracketed expression in the assignment will fail compiling with the above error.

 

Minimal example:

class Test
{
template< typename Foo >
static constexpr bool UseSMPAssign_v =  (true || false) && true ;
};

int main(int argc, char** argv)
{
    return 0;
}

Expected Result:

Minimal example compiles without errors

Actual Result:

Compilation Fails with

testmain2.cpp(4): error: expected a ")"
  static constexpr bool UseSMPAssign_v =  (true || false) && true ;
                                                 ^

compilation aborted for testmain2.cpp (code 2)

Other Compilers:

GCC 8.3 and 9.2 are compiling the example

Note:

() are needed here to logically structure the expression without relying on which order operators are executed according to the standard. Pretty sure, that there are cases constructible , which do not work without ().

 

0 Kudos
Viet_H_Intel
Moderator
1,414 Views

I see. Hopefully, the fix will be in the next update compiler.

0 Kudos
Mueller__Tobias
Beginner
1,414 Views

The fix apparently did not make it into the latest version (19.1.1.217)

0 Kudos
Viet_H_Intel
Moderator
1,416 Views

Sorry for the inconvenient; 19.1.1.217 was built on Mar-6 (same day that this issue reported). Hence the fix couldn't be able to make it in.

0 Kudos
Mueller__Tobias
Beginner
1,395 Views

Bug is still present in ICPC 19.1.2.254.

0 Kudos
Viet_H_Intel
Moderator
1,387 Views

It will be fixed in the next major release compiler.



0 Kudos
Viet_H_Intel
Moderator
1,163 Views

This issue is fixed in oneAPI2021.2.

$ icpc -V

Intel(R) C++ Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.2.0 Build 20210228_000000


I am going to close this thread.


0 Kudos
Reply