- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sample code:
enum { x = (int)(0.0 + 0.0) };
Invocation: icl -std=c11 -Wall -Wextra -pedantic
Expected diagnostics: warning: expression is not an integer constant expression
Actual diagnostics: <nothing>
Version: icc 2021.1.2 on x86-64 on Linux
C11, 6.6 Constant expressions, 6:
> An integer constant expression 117) shall have integer type and shall only have operands
that are integer constants, enumeration constants, character constants, sizeof
expressions whose results are integer constants, _Alignof expressions, and floating
constants that are the immediate operands of casts. Cast operators in an integer constant
expression shall only convert arithmetic types to integer types, except as part of an
operand to the sizeof or _Alignof operator.
Also: it seems that this diagnostic is required under -strict-ansi as well.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thank you for posting in Intel Communities.
We are also able to reproduce your issue at our end.
We are working on this internally and we'll get back to you soon.
Meanwhile, could you please try with icx compiler?
Thanks and Regards,
Ditipriya.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Looks like Intel compiler misses a warning on this case. I'll see if there is another option to catch this issue.
Not sure if you are aware of, but C++ Classic compiler will be enter "Legacy Product Support" mode signaling the end of regular updates. Please see https://www.intel.com/content/www/us/en/developer/articles/technical/adoption-of-llvm-complete-icx.html
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't think we have a way to get a diagnostic on this from Classic C++ Compiler.
Is this an important diagnostic that you would like Classic C++ Compiler to be able to emit?
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Viet_H_Intel As I understand, "icx compiler" is a C++ compiler. From the "Invocation" we see that the language is C, not C++. The 6.6 Constant expressions, 6 is in Semantics section, not Constraints, so no diagnostic is required, but as a quality-of-implementation matter Intel C compiler should diagnose it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
On Linux icx is a driver for C code whereas icpx is a driver to C++ code.
And on Windows icx is a driver for both C and C++. Looks like icx on Windows isn't emit this warning.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I didn't use a corrected flag on my last post regarding icx on Windows.
icx actually emits a warning:
> icx t.c -c -Wpedantic
Intel(R) oneAPI DPC++/C++ Compiler for applications running on Intel(R) 64, Version 2022.0.0 Build 20211123
Copyright (C) 1985-2021 Intel Corporation. All rights reserved.
t.c(1,12): warning: expression is not an integer constant expression; folding it to a constant is a GNU extension [-Wgnu-folding-constant]
enum { x = (int)(0.0 + 0.0) };
^~~~~~~~~~~~~~~~
1 warning generated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I've reported this issue to our Front End team.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The fix is in the upcoming oneAPI 2022.3 release.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page