Bug #18184 2011-06-25 12:21
m1dyyy
-Wunreachable-code doesn't correctly detect unreachable code
Compiler flag does not correctly recognize unreachable code.
Below steps to reproduce:
1. Set compiler flag -Wunreachable-code
2. Write code (on Windows):
//Snippet #1 [generates warning: "will never be executed"]:
#include <iostream>
using namespace std;
int main() {
cout << "This line is reachable" << endl;
//this line is unreachable regarding -Wunreachable-code.
int* x = new int(56);
cout << *x << endl; //obviously prints 56
cout << "This line is reachable too" << endl;
return 0;
}
//Snippet #2 [generates NO warnings]:
#include <iostream>
using namespace std;
int main() {
cout << "This line is reachable" << endl;
int* x = new int;
*x = 56;
cout << *x << endl;
cout << "This line is reachable too" << endl;
return 0;
}
- Category
- Application::WrongBehaviour
- Group
- Status
- Closed
- Close date
- 2011-06-30 06:31
- Assigned to
History
Neither of the two code snippets contain any unreachable code.
In any case, this would be unrelated to Code::Blocks, as it's a matter of the compiler you're using.
Report to MinGW/GCC team. Not a C::B issue.