1

A recent minor release version of Visual Studio (15.7) implements the compiler switch /permissive-, which among other effects, enables two-phase name lookup for templates (https://learn.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance). I'd like to enable this switch on our codebase of about 4M lines of code. The problem is, the instantiated templates might change if this switch is enabled (see the first example at https://blogs.msdn.microsoft.com/vcblog/2017/09/11/two-phase-name-lookup-support-comes-to-msvc/), which lead to silent changes in the run-time behavior.

Is there a way to check whether the code generated with this conformance switch enabled is identical to the old code?

I'm aware that the correct answer is "you run your unit tests, duh!". Sadly with the amount of legacy code lying around, this is out of reach for the next couple of years, so I'm looking for an alternative.

Doing a compare on the binaries does not help, since there are differences present due to metadata changes. New compilation errors aren't really of any help either: they only expose non-conforming syntax; changes in generated code can still be hidden. Actually seeing the generated code is not important. A tool showing "this line will compile differently" would be sufficient. Or something similar to what "Preprocess to a File" does for the preprocessor.

The best I can think of is checking generated symbols via the dumpbin tool on every .obj file to see whether the same ones are being generated. This can expose only a subset of issues: the set of template instances in a file might be identical, but their locations in the code might be change.

Silvester
  • 421
  • 5
  • 13
  • How about analyzing differences at the assembly level produced by compiler? https://stackoverflow.com/questions/1020498/how-to-view-the-assembly-behind-the-code-using-visual-c – roalz Aug 30 '18 at 08:11
  • @roalz That's incredibly useful. I did not know of this feature. If you put that down as an answer, I'll accept it. – Silvester Aug 30 '18 at 11:29

1 Answers1

2

You may analyze the compiler output (at assembly level) to check for differences generated with the 2 compiler settings you mentioned.

Please look at this related SO question about Visual C++ compilers.

Also, better suited for relatively small portions of code,
you may want to use the marvelous GodBolt's Compiler Explorer,
that does the same task but with an handy web interface and extended to various compilers (not only Microsoft Visual C++).
I'm sure it will become one of the most valuable tools in your developer's toolset.

roalz
  • 2,699
  • 3
  • 25
  • 42