Visual Studio and .NET Framework Home
Arrays decay into pointers in conditional operator
Ben Voigt - old ID
as Won't Fix
5/31/2007 7:28:37 AM
User(s) can reproduce this bug
If T is a template parameter which is a reference to an array, T decays
unnecessarily into a pointer in the conditional operator.
This bug report is submitted at the request of Matthias Hoffman, please see thread "Explicitly specializing std::min() on VC++ 2005 Express Edition" on microsoft.public.vc.language
Visual C#, C++, J#, or Visual Basic Express Service Pack 1
Windows XP Professional
Operating System Language
Steps to Reproduce
Compile the following code:
template <class T> struct minimum_impl
static const T& minimum(
const T& a, const T& b )
return a < b ? a : b;
template <std::size_t N> struct minimum_impl<char[N]>
static const char (& minimum( const char (&a)[N],
const char (&b)[N] ) )[N]
// Error C2440 here.
return std::strcmp( a, b ) < 0 ? a : b;
template <class T> inline
const T& minimum( const T& a, const T& b )
return minimum_impl<T>::minimum( a, b );
char a = "a";
char b = "b";
std::cout << minimum( a, b ) << std::endl;
Gives a C2440 error.
Should compile without an error.
TAP Code (if applicable)
You can indicate your satisfaction with how Microsoft handled this issue by completing this quick
3 question survey
to post a comment.
Please enter a comment.
on 6/5/2007 at 3:29 PM
Thank you for sending us feedback. The Visual C++ team has evaluated the bug and determined it does not meet the guidelines necessary to warrant a fix. To understand these guidelines please refer to http://blogs.msdn.com/vcblog/articles/621116.aspx.
Unfortunately, the Visual C++ development team cannot provide workarounds for issues submitted via the Microsoft Connect interface. The MSDN forums are better suited for finding the correct answer. Visit the MSDN forums at http://forums.microsoft.com/msdn/default.aspx.
Comments from the triage team: This does not meet the triage guidelines for Orcas. Please consult the forums for assistance.
Thanks once again for taking the time to send us feedback,
The Visual C++ Triage Team
on 5/31/2007 at 5:26 PM
Thank you for your feedback. We are currently investigating. If this issue is urgent, please call support directly (see http://support.microsoft.com). Thank you, Visual Studio Product Team.
Ben Voigt - old ID
on 5/31/2007 at 7:32 AM
This issue is similar to item #101496, but this variation is still handled incorrectly in SP1.
to post a workaround.
Please enter a workaround.
© 2014 Microsoft