Delete code unavailable for removal? (-Wunreachable code)

I have an older program that was built using clang via CFLAGS = "- Wunreachable-code" and displays some warnings for a specific switch () on break; where it says that it will never be executed, it’s safe to simply delete the unreachable code or be a beta version of beta blogs in nature?

In particular, it gives warnings on several functions, i.e. returns -1 after the previous return and breaks inside switch ()

+3
source share
3 answers

Read the code, understand it, and if the code marked as unreachable is really unavailable, and it is not unreachable due to a logical error, you can simply delete it. If you have not read the code and do not understand it, then it is unsafe to modify it no matter what the compiler says.

+10
source

I am sure the warning is conservative, i.e. it will not be provided if the compiler is not sure if this is unreachable code.

+1
source

I just found the following link:

http://old.nabble.com/gcc--Wunreachable-code-option-td31698329.html

This option has been removed because it is unstable. For more details, see the mailing section.

+1
source

All Articles