- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
GCC has supported __attribute__((__fallthrough__)) since version 7. ICC claims __GNUC__ >= 7, though it does not support the fallthrough attribute.
Perhaps more problematically (I'm used to compilers lying about __GNUC__), as of version 2021.2.0, ICC now advertises support for the fallthrough attribute via __has_attribute(fallthrough). Earlier versions (even those which define the __has_attribute macro) do not make this claim.
int foo(int bar) {
int r = 0;
switch (bar) {
case 0:
r += 1;
#if defined(__has_attribute) && __has_attribute(fallthrough)
__attribute__((__fallthrough__));
#endif
case 1:
r += 2;
break;
}
return r;
}
Results in "warning #2621: attribute "__fallthrough__" does not apply here".
Here is a link to the example on godbolt: https://godbolt.org/z/senjfaoao
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks for reporting this issue. ICC throws a warning with the 2021.2 version. We are working on this internally and will get back to you with an update.
Thanks,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Probably related: I just noticed that __has_cpp_attribute(clang::fallthrough) also returns true, but [[clang::fallthrough]] generates "warning #3924: attribute namespace "clang" is unrecognized".
Test on Compiler Explorer: https://godbolt.org/z/ExadrM8ve
Similarly, __has_cpp_attribute(fallthrough) returns true, but [[fallthrough]] generates a "warning #1292: unknown attribute "fallthrough"": https://godbolt.org/z/6j3jGK4qn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This issue has been fixed in oneAPI 2021.3. 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,

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page