- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In the following code snippet, the conversion operator for a vector-of-strings is not used. Instead the compiler prefers a template version for a vector-of-T with T=string. The overload should be chosen over the template.
This is not what VS2003 does, and I think Intel compiler does it incorrectly.
---------------------------------------------
#include
#include
#include
struct A
{
// conversion to a vector-of-strings
inline operator std::vector<:STRING> () const
{
std::cout << "operator std::vector<:STRING> ";
return std::vector<:STRING>();
}
// conversion to a vector-of-T
template
inline operator std::vector () const
{
std::cout << "operator std::vector
";
return std::vector();
}
};
int main()
{
const A a;
// uses the apropriate conversion
std::vector vod = a;
// uses the wrong conversion!
std::vector<:STRING> vos = a;
return 0;
}
---------------------------------------------
expected output is (as given by VS2003):
operator std::vector
operator std::vector<:STRING>
wrong result is (given by intel):
operator std::vector
operator std::vector
Is this a bug? compiler is Intel C++ compiler for Windows 9.1.038
Thanks in advance
This is not what VS2003 does, and I think Intel compiler does it incorrectly.
---------------------------------------------
#include
#include
#include
struct A
{
// conversion to a vector-of-strings
inline operator std::vector<:STRING> () const
{
std::cout << "operator std::vector<:STRING> ";
return std::vector<:STRING>();
}
// conversion to a vector-of-T
template
inline operator std::vector
{
std::cout << "operator std::vector
return std::vector
}
};
int main()
{
const A a;
// uses the apropriate conversion
std::vector
// uses the wrong conversion!
std::vector<:STRING> vos = a;
return 0;
}
expected output is (as given by VS2003):
operator std::vector
operator std::vector<:STRING>
wrong result is (given by intel):
operator std::vector
operator std::vector
Is this a bug? compiler is Intel C++ compiler for Windows 9.1.038
Thanks in advance
Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
VC6 gives the same output as IntelC. VC2003 changed.
It is a bug. Could you please file an issue report at Premier Support? So when the fix is available, you'll be notified. I'll also try to update here as well.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Checked against VS2005 and gcc 3.4.4, got same result (correct) as VS2003
Checked against Intel Compiler 10.0.025, got same result (incorrect) as ICL 9.1.038
Reported to Intel Premier Support: Issue number 454864.
Checked against Intel Compiler 10.0.025, got same result (incorrect) as ICL 9.1.038
Reported to Intel Premier Support: Issue number 454864.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for submitting the issue at PremierSupport.
There's a work-around for this /Qms0.It tells the compiler to emulate the fewest number of Microsoft compatibility bugs (this is an old bug).
Hope it won't bring anything else up when compiling the whole app.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just so we are clear. This is not a MS bug. The section 14.5.2.2 of the C++ standard says that when you have both, a template and a non-template member function with the same name, the non-template one should be called, unless template arguments explicitly used.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, you're right. I didn't make it clear.
VC2003/VC2005 has the correct behavior, no bug here. It's a bug in icl with /Qvc7.1 and above.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hum. I don't feel very comfortable changing the level of compatibility emulation with MS compiler.
I think for now I'd rather change the code to avoid calling the conversion operator for this case, as genericity is not strictly required (but it is still desired!).
I'll just have something like getAsVectorOfStrings() and make the template version not work for strings. I'll retake the conversion approach when a fix is available.
Thanks.
I think for now I'd rather change the code to avoid calling the conversion operator for this case, as genericity is not strictly required (but it is still desired!).
I'll just have something like getAsVectorOfStrings() and make the template version not work for strings. I'll retake the conversion approach when a fix is available.
Thanks.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page