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

icpx -fpermissive ICE in IntExprEvaluator::VisitCastExpr

vzecca
Beginner
1,278 Views

The following code provokes an ICE in icpx Version 2021.1 NextGen Beta Build 20200304

// icpx -fpermissive ICE in IntExprEvaluator::VisitCastExpr
enum E { EA, EB };

struct A { E e: 8; };

A a = { 0 };

Labels (1)
0 Kudos
4 Replies
PrasanthD_intel
Moderator
1,264 Views

Hi Vittorio,


Thanks for reaching out to us.

You are getting an error because you cannot convert an enum into int type a. 

But since you are using -fpermissive, it will make the compiler to report some things that are actually errors (but are permitted by some compilers) as warnings, to permit code to compile even if it doesn't conform to the language rules.


You will get the same error with g++, icpc or clang++.

What is the use case you are trying to achieve?


Regards

Prasanth


0 Kudos
vzecca
Beginner
1,254 Views

g++ -fpermissive compiles with a warning, while icpc -fpermissive compiles without warnings.

This snippet code is part of a huge code that compiles and run with g++ -fpermissive

AND with icpc -fpermissive.

I do not understand why icpx crashes, instead of just giving an error message

and gracefully terminate.

0 Kudos
Viet_H_Intel
Moderator
1,242 Views

The compiler shouldn't give you a core dump. I'll report that to our Developer.

If you have later icpx version, then -fpermissive (for gnu extension for non conformant code) won't longer be supported (I think it's because clang doesn't support it)

$ cat t4.cpp

enum E { EA, EB };


struct A { E e: 8; };


A a = { 0 };


$ icpc t4.cpp -fpermissive -c

$ g++ t4.cpp -fpermissive -c

t4.cpp:5:11: warning: invalid conversion from ‘int’ to ‘E’ [-fpermissive]

 A a = { 0 };

      ^

$ clang++ t4.cpp -fpermissive -c

error: unknown argument: '-gnu-permissive'

$ icpx t4.cpp -fpermissive -c

error: unknown argument: '-gnu-permissive'


You can use -fgnu-keywords for Gnu extension with icpx instead

$ clang++ t4.cpp -c -fgnu-keywords

t4.cpp:5:9: error: cannot initialize a member subobject of type 'E' with an rvalue of type 'int'

A a = { 0 };

    ^

1 error generated.

$ icpx t4.cpp -c -fgnu-keywords

t4.cpp:5:9: error: cannot initialize a member subobject of type 'E' with an rvalue of type 'int'

A a = { 0 };

    ^

1 error generated.

$

Keep in mind that icpx is compatible with clang, so you may find issues when porting from icpc/g++ to icpx/clang.




0 Kudos
Viet_H_Intel
Moderator
1,053 Views

This issue has been resolved in oneAPI  2021.1.2. We will no longer respond to this thread.  

If you require additional assistance from Intel, please start a new thread. Any further interaction in this thread will be considered community only.

Thanks,



0 Kudos
Reply