C++ inconsistency between gcc and clang

后端 未结 1 1806
一向
一向 2021-01-01 10:17

I came across a C++ inconsistency between gcc (versions 4.8.1, 4.8.2) and clang (versions 3.3, 3.4

相关标签:
1条回答
  • 2021-01-01 11:14

    I remember a WG21 core discussion about this, and one of the Clang developers defended their position by citing 14.7.1p7

    If the overload resolution process can determine the correct function to call without instantiating a class template definition, it is unspecified whether that instantiation actually takes place.

    On the other hand, for an ill-formed program (which is the case here when doing the required instantiation), there is no such notion of "the correct function to call", so I agree to the position of another guy in that discussion who said that he can't see that this allows Clang to go that route.

    In the example of p7 it shows code that is well-formed both with and without doing the additional instantiation.

    In any case, even if Clang is allowed to do it, the well-formedness of your program would then rely on particular happenstances (unspecified behavior). The Standard therefore doesn't anymore require your program to be accepted, and honestly I don't know what that means. I regard such code as being ill-formed.

    0 讨论(0)
提交回复
热议问题