Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.

Templates: two-phase name lookup

isnullxbh
Beginner
631 Views

Live example: https://godbolt.org/z/TqM35b
Env.: macOS 10.15.7,  ICC 2021.1 Beta 20201112

The following example compiles without error, but the internalCheck function doesn't depend on one of the template parameters, so we should get a compile-time error (according to the https://eel.is/c++draft/temp.res#general-10)

template<typename Context,
         typename Protocol>
auto createSocket(Context& context, const Protocol& protocol) -> auto
{
    using Socket = typename Protocol::Socket;
    internalCheck();
    return Socket { context, protocol };
}

 

0 Kudos
1 Solution
Viet_H_Intel
Moderator
587 Views

Our Developer said: "This is not really a bug; but perhaps a compatibility/usability issue (Microsoft doesn't emit error)"

The C++ standard does not require a compiler to give diagnostics on a template that has not been used/instantiated.

From the standard: This is a quality of implementation issue, it is ill-formed but if it is not instantiated no diagnostic is required as per [temp.res#8.1]p:

The validity of a template may be checked prior to any instantiation. [ Note: Knowing which names are type names allows the syntax of every template to be checked in this way. — end note ] The program is ill-formed, no diagnostic required, if:

no valid specialization can be generated for a template or a substatement of a constexpr if statement within a template and the template is not instantiated.


Thanks,


View solution in original post

5 Replies
RahulV_intel
Moderator
607 Views

Hi,


Thanks for reporting this bug. I have escalated this to the concerned team for a fix.


Regards,

Rahul


Viet_H_Intel
Moderator
593 Views

Thank you for reporting this issue. I've filed a bug with our compiler Developer.


Viet_H_Intel
Moderator
588 Views

Our Developer said: "This is not really a bug; but perhaps a compatibility/usability issue (Microsoft doesn't emit error)"

The C++ standard does not require a compiler to give diagnostics on a template that has not been used/instantiated.

From the standard: This is a quality of implementation issue, it is ill-formed but if it is not instantiated no diagnostic is required as per [temp.res#8.1]p:

The validity of a template may be checked prior to any instantiation. [ Note: Knowing which names are type names allows the syntax of every template to be checked in this way. — end note ] The program is ill-formed, no diagnostic required, if:

no valid specialization can be generated for a template or a substatement of a constexpr if statement within a template and the template is not instantiated.


Thanks,


isnullxbh
Beginner
554 Views
Viet_H_Intel
Moderator
512 Views

We are closing the thread as the issue has been resolved and we will no longer respond to this thread. If you require additional assistance from Intel, please start a new thread. Any further interaction in this thread will be considered community only.

Thanks,


Reply