- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm getting a ton of invalid warnings from ICC about an __assume with side effects. It turns out the "problem" is that I'm using a statement expr (which has no side effects). Here is a reduced test case:
#include <stdint.h> void foo(int *bar) { __assume(( ((uintptr_t) bar) % 16) == 0); __assume(( (__extension__ ({ (uintptr_t) bar; })) % 16) == 0); }
Which triggers:
aa.c(8): warning #2261: __assume expression with side effects discarded __assume(( ^
I've already tweaked my code to get rid of the statement expr, so no need to think of work-arounds on my behalf. I just wanted to report the issue.
- Tags:
- CC++
- Development Tools
- Intel® C++ Compiler
- Intel® Parallel Studio XE
- Intel® System Studio
- Optimization
- Parallel Computing
- Vectorization
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I see two potential issues:
1) the extension contains a braced group
2) more importantly, bar is followed by a statement terminator ;, which means %16 is without a lhs operand
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
GNU also emits a warning
$ gcc t.c -c
t.c: In function ‘foo’:
t.c:4:3: warning: implicit declaration of function ‘__assume’ [-Wimplicit-function-declaration]
__assume((
^~~~~~~~
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry about the delayed response.
jimdempseyatthecove (Blackbelt) wrote:I see two potential issues:
1) the extension contains a braced group
2) more importantly, bar is followed by a statement terminator ;, which means %16 is without a lhs operand
That's not a braced group, it's a statement expr. It's an extension available in gcc-2.95+ as well as clang, icc back to at least version 9, PGI, Oracle Developer Studio 5.12+, XL C/C++ 11+, Cray since at least 8.1, tinycc 0.9.26+, armcc since at least 4.1, The only compilers I know don't support statement exprs are MSVC, Pelles, Digital Mars C, and I *think* IAR but I'd have to check on that.
It's basically a way of putting multiple statements inside of an expressions which is very useful for macros.
Viet Hoang (Intel) wrote:GNU also emits a warning
$ gcc t.c -c
t.c: In function ‘foo’:
t.c:4:3: warning: implicit declaration of function ‘__assume’ [-Wimplicit-function-declaration]
__assume((
^~~~~~~~
Yes, GCC doesn't support __assume. ICC does, I believe as part of its efforts towards MSVC compatibility. The closest thing in GCC would be something like `#define __asume(expr) ((expr) ? ((void) 0) : __builtin_unreachable())`. Recent versions of clang do support a __builtin_assume, here is quick example on Compiler Explorer: https://godbolt.org/z/4yC8gR.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can also suppress the warning via -wd2261. Let's us close this case.

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