- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Compiling the following piece of code produces unnecessary warnings (warning #175: subscript out of range) with icpc version 13.0.0 (gcc version 4.6.3 compatibility), could you please tell me why ? Template parameters are evaluated at compile time before code generation right ?
[cpp]template<int T> void fun() {
int foo[2 + (T == 0)];
if(T == 0)
foo[2] = 2;
else
foo[1] = 2;
}
int main()
{
fun<2>();
fun<0>();
}
[/cpp]
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Georg Zitzlsberger (Intel) wrote:GCC doesn't detect such potential problems indeed, however clang (3.0 or newer) does it, and better than icc (no warning at all with -Warray-bounds, which is the expected behavior).
Other compilers are known to not detect potential problems like that at all. So, we could regard this as an additional benefit to warn about such potential problems, even though we're overly sensitive.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Why is this still not fixed ?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I've had a look at the feature request. The problem here is that it would require large changes in the compiler FE to do the analysis. Trading off the amount of work needed for getting rid of a warning, we have refrained from implementing this feature request.
Nevertheless, you can turn off warnings like that if you want: -diag-disable=175 or /Qdiag-disable:175
Best regards,
Georg Zitzlsberger
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page