Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
7569 Discussions

Parsing Error templated constexpr member variable

Mueller__Tobias
Beginner
461 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
461 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

Viet_H_Intel
Moderator
461 Views

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

Mueller__Tobias
Beginner
461 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 ().

 

Viet_H_Intel
Moderator
461 Views

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

Mueller__Tobias
Beginner
461 Views

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

Viet_H_Intel
Moderator
461 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.

Mueller__Tobias
Beginner
440 Views

Bug is still present in ICPC 19.1.2.254.

Viet_H_Intel
Moderator
432 Views

It will be fixed in the next major release compiler.



Viet_H_Intel
Moderator
208 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.


Reply