Community
cancel
Showing results for 
Search instead for 
Did you mean: 
NathanH
Beginner
408 Views

Bug Report: icc 19 emitting incorrect warnings for C11 atomics

Putting this in the C++ forum as there is no forum for the C compiler.

We have a code that support C11 and it needs to compilable (without warnings) with icc. The problem is that we see warnings like this when using the atomic types (ex. _Atomic int) with the atomic function (ex. atomic_exchange). These warnings suggest that icc is not correctly defining the C11 atomic functions.

Example code (valid C11):

 

```

#include <stdatomic.h>

 

int main (int argc, char *argv[]) {

  _Atomic int foo = 0;

 

  atomic_exchange (&foo, 1);

 

  return 1;

}

```

 

Warnings:

```

icc icc_atomic_reproducer.c

icc_atomic_reproducer.c(6): warning #2330: argument of type "_Atomic(int) *" is incompatible with parameter of type "volatile void *" (dropping qualifiers)

    atomic_exchange (&foo, 1);

    ^

```

 

atomic_exchange (like all atomics) is defined to be a _Generic function with the first argument of the form volatile _Atomic <something>*.

 

This warning shows that icc is in clear violation of ISO C11. This warning appears in icc 18 as well.

 

0 Kudos
3 Replies
PrasanthD_intel
Moderator
377 Views

Hi Nathan,


We have tried the reproducer code you have given with icc(19.1.1.217) and we are getting an error as below:

$ icc atomic_test.c

atomic_test.c(7): error: identifier "_Atomic" is undefined

  _Atomic int foo = 0;

  ^

atomic_test.c(7): error: expected a ";"

  _Atomic int foo = 0;

      ^

atomic_test.c(11): error: identifier "foo" is undefined

  atomic_exchange (&foo, 1);

  ^


You have mentioned that you are getting only a warning.

Can you confirm that the reproducer code is complete? or are we missing anything?



Thanks

Prasanth



Viet_H_Intel
Moderator
355 Views

We will addressed this issue in the next release.


Viet_H_Intel
Moderator
61 Views

This issue is fixed in oneAPI 2021.2. Hence, we are going to close 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


$ icc test.c -V

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

Copyright (C) 1985-2021 Intel Corporation. All rights reserved.


Edison Design Group C/C++ Front End, version 5.1 (Feb 28 2021 02:56:56)

Copyright 1988-2019 Edison Design Group, Inc.


GNU ld version 2.30-58.el8

$ cat test.c

#include <stdatomic.h>



int main (int argc, char *argv[]) {


 _Atomic int foo = 0;


 atomic_exchange (&foo, 1);


 return 1;


}



Reply