- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[cpp]struct tag1{}; struct tag2{}; struct data1{ typedef double value; }; struct data2{ //Doesn't have a ::value member }; templatestruct my_meta1 { typedef typename T::value value; }; template struct my_meta2 { typedef double value; }; //Matching the function based on the tag type template typename my_meta1 ::value f(tag1, DataType data) { return 0.0; } template typename my_meta2 ::value f(tag2, DataType data) { return 0.0; } int main() { f(tag1(), data1()); //Should match the tag1 specialization, which in turn gets the metadata from the data1() struct f(tag2(), data2()); //Should match the tag2 specialization, which doesn't need to call anything on data2()\ return 0; } [/cpp]
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I entered this test case to our problem-tracking database and let engineering team to take a look. They will see whether icc should report an error against this test case or not.
Thanks,
Feilong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thanks for reporting it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Engineering team has implemented a fix for this issue in the next major version of the compiler. I'll let you know when it is available for download.
Thanks,
Feilong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is a description of the fix we made. This does not fall under SFINAE because the argument mismatch is not a result of substitution.
Templates rejected on non-dependent parameters before deduction
In overload resolution, function templates are now rejected before deduction
is done if it can be shown that any of the non-dependent parameters cannot
match. If all those parameters are okay, deduction is then done and the
remaining parameters are checked. This can speed up overload resolution,
and in some cases avoids errors caused by instantiations needed to develop
the function type. For example:
template
typedef T::x xx;
};
template
template
struct A {} a;
int main() {
f(1, a); // Okay now. Formerly provoked an error on the instantiation
// of the Z
// is ruled out on the basis of the first parameter without
// doing deduction and producing the routine type.
}
The C++ standard does not mandate a particular behavior here; it allows
but does not require such instantiations. However, test cases like the
above are accepted by recent versions of g++, and it seems reasonable to
do so.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The latest intel compiler (Intel C++ Compiler XE 12.0 Update 2) contains the fix for this issue. You may download it at https://registrationcenter.intel.com.
Thanks,
Feilong

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page