GCC seems to be much more permissive regarding template code that is never instantiated than Clang is. I have a codebase that compiles without warning or error using g++-5.1 (using -Wall -Wextra -Wdeprecated -Wno-comment -Wnoexcept), but emits many errors regarding template code using clang++-3.7 unless I specify -fdelayed-template-parsing. The documentation on this flag is pretty scarce; all I can find is a single sentence describing its behavior:
-fdelayed-template-parsinglets clang delay parsing of function template definitions until the end of a translation unit.
Even this seems like it might be incorrect--I think the problem is that the templates are being parsed at all, and that the flag is actually allowing Clang to complete the compile without ever parsing the templates in question.
So I'd like to know:
- How similar is the behavior of
-fdelayed-template-parsingto the default behavior of GCC? The option itself is based on MSVC, which, as the flag-name implies, doesn't even check for basic syntax issues such as missing semicolons in uninstantiated template code. I believe GCC goes a little further than MSVC here, so does this flag actually make Clang less restrictive than GCC? - Going the other way, is there a way to make GCC behave more like Clang in this respect, by issuing an error, or at least a warning, for illegal code inside of uninstantiated templates?
Aucun commentaire:
Enregistrer un commentaire