Re: <infiniband/verbs.h> & ICC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 23, 2019 at 03:57:29PM -0700, Gerd Rausch wrote:
> Hi Jason,
> 
> Trying to compile <infiniband/verbs.h> with ICC (Intel's C/C++ Compiler)
> leads to the following error:
> 
> error: enumeration value is out of "int" range
>          IBV_RX_HASH_INNER = (1UL << 31),

I assume you are running with some higher warning flags and -Werror?
gcc will not emit this warning without -Wpedantic

Also, I think icc is broken to emit these kinds of pedantic warnings
on a system header, gcc does not do that.

> IMO, ICC is correct here, because according to ISO-C99:
> 6.4.4.3  Enumeration constants
>  Semantics
>   identifier declared as an enumeration constant has type int

Sure

> Since "int" is signed, it can't hold the unsigned value of 1UL<<31
> on target platforms with sizeof(int) <= 4.

Pedentically yes, but gcc and any compiler that can compile on linux
supports an extension where the underlying type of an enum constant is
automatically increased until it can hold the value of the
constant. In this case the constant is type promoted to long,
IIRC.

See my past writing on this topic:

https://www.spinics.net/lists/linux-rdma/msg36828.html

FOO_VALUE2 automatically has the type of long because it cannot be
represented by an int.

> (In other words: that would be the sign-bit on two's complement machines).

No, either the compiler supports the extension or it should refuse to
compile the code.

> Can you shed some light on whether or not verbs.h is supposed
> to compile with ICC (i.e. if it's supported), and what the level
> of appetite is to make this work?

Generally we use many gcc extensions in verbs headers and expect the
compiler to support them, this is just one of many. So I'm not
particularly thrilled to have to support weird compilers. Particularly
if the compilers just need to use the right option flags.
 
> It's trivial to fix this, but there's benefit in making this part
> of a regression test suite (e.g. Travis).

Can you clarify if icc is being run in some wonky mode that is causing
this warning? AFAIK icc will compile the linux kernel, and the kernel
makes extensive use of this extension. So I think the compiler is not
configured properly.

IIRC I looked at this once for -Wpedantic support and decided it was a
lot of work as there are more cases than just this.

Jason




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux