Why an incomplete type is detected in clang inside a template method?

前端 未结 1 1167
被撕碎了的回忆
被撕碎了的回忆 2021-01-21 02:45

Today, I encountered a compile issue in clang that surprised me. I guess is reasonable but I like to dig deeper and hear more details. Some standard references if possible also.

相关标签:
1条回答
  • 2021-01-21 03:40

    Yes, this compiles in MSVC because it has a well-known bug. It doesn't implement two-step template instantiation.

    To elaborate. MSVC wrongly defers template parsing until it is actually instantiated in the code. Likely it happens after full Page definition becomes visible.

    However, standard demands that the template is pre-parsed at the point of definition, and all types which are not dependent on template arguments are resolved. This fails, since m_page is not dependent on visitor argument - and it is still incomplete type at this point.

    P.S. I can't even express how outraged I am at MSFT for this blatant Standard violation (among others). It makes cross-platform development a real pain, when MS-compliant code has to be ported to conforming compilers.

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