News:

Simutrans Tools
Know our tools that can help you to create add-ons, install and customize Simutrans.

Fix "Unreachable code" warnings

Started by eipi, October 09, 2013, 08:42:20 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

eipi

Hi,

I made a patch to fix "unreachable code" warnings popping up in MSVC.
There are still some warnings, namely return statements after calls to dbg->fatal(). I did not touch them because I'm unsure whether removing them will trigger new warnings in gcc. (Don't have access to gcc atm so I can't test it.)

prissi

Some of those examples does not seem identical at first glance. You also mixed some reformatting into it.

On a different note: having a function to return a value at the end has been considered good practice (by some) in case the function is changed and will now reaches there.

If I do this I get some warnings that functions should return a value. I never got an unreachable code warning in MSVC so far. What kind of settings do you use? (If this is an MSVC 2012 warning, well the latest MSVC express does no longer install on XP.) So I will have to check it a home.

eipi

Quote from: prissi on October 09, 2013, 09:22:35 AM
If I do this I get some warnings that functions should return a value. I never got an unreachable code warning in MSVC so far. What kind of settings do you use? (If this is an MSVC 2012 warning, well the latest MSVC express does no longer install on XP.) So I will have to check it a home.

You can enable unreachable code messages by adding  /w3"4702" in Project Properties > C/C++ > Command Line. This will set the unreachable code warning to appear as a level 3 warning. The warning is disabled by default.