- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[cpp]
int main() {
switch(0) {
default:
}
}
[/cpp]
This code must not compiles(as it is on gcc/msvc) because it's need ";" before "}".
ICC 13 update 1 on win.
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, Bert. However, Intel C++ compiler actually displays a warning #127 ( expected a statement ).
>>switch(0) {
>>default:
>>}
I've done a quick verification and here are compilation outputs for different C++ compilers:
[ Intel C++ compiler ]
...
.\../../Common/PrtTests.cpp(8745): warning #127: expected a statement
}
^
[ Microsoft C++ compiler ]
...
..\prttests.cpp(8745) : error C2143: syntax error : missing ';' before '}'
..\prttests.cpp(8745) : warning C4065: switch statement contains 'default' but no 'case' labels
[ MinGW C++ compiler ]
...
../../Common/PrtTests.cpp:8745: error: expected primary-expression before '}' token
../../Common/PrtTests.cpp:8745: error: expected `;' before '}' token
[ Borland C++ compiler ]
...
Error E2379 ../../Common/PrtTests.cpp 8745: Statement missing ; in function RunTest1017()
[ Turbo C++ compiler ]
...
Error ../../Common/PrtTests.cpp 8745: Statement missing ; in function RunTest1017()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, because of some troubles i have all warnings disabled on icc.
But anyway it should be en error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I agree to Sergey that the warning usually should be enough here. If someone really wants this to be an error, the option /WX (warnings to errors) can be used.
Nevertheless, Microsoft Visual Studio* compiler treats it as an error and maybe we should too, for compatibility reasons. Hence, I've asked engineering to raise severity of this warning to an error.
Edit:
Created ticket for this feature request: DPD200240577
It also is only a warning on Linux* but an error with GNU GCC*.
Best regards,
Georg Zitzlsberger
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>>...But anyway it should be en error.
Yes and here is additional verification with a 23-year-old Turbo C++ compiler:
[ Turbo C++ Version 1.01 ]
...
Turbo C++ Version 1.01 Copyright (c) 1990 Borland International
test.c:
Error test.c 6: Statement missing ; in function main
*** 1 errors in Compile ***
...
[ Test-case ]
void main( void )
{
switch( 0 )
{
default:
}
}
PS: That is a really good catch!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
just FYI: DPD200240577 has been rejected.
ICC is more tolerant by default here and there is a way to turn warnings into errors (/WX) in case you still want strict checking.
Best regards,
Georg Zitzlsberger

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