Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / March 2005

Tip: Looking for answers? Try searching our database.

another .2003 issue to be verified

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Stefan Slapeta - 18 Mar 2005 12:05 GMT
VC 2003 calls f(char const*) for the following code, but it should call
the function template as f(char const*) is no perfect match (because of
decay).

Please could someone analyze the behaviour in VC .2005?

Thanks, Stefan

template <typename T>
void f(T const&)
{
// this one should be called!
}

void f(const char *)
{
}

int main()
{
    char buf[] = "abc";
    f(buf);
}
Stefan Slapeta - 18 Mar 2005 12:07 GMT
[...]

BTW, seems to no be no open issue for this; I'm going to submit one if
VC 2005 is still wrong.

Stefan
David Lowndes - 18 Mar 2005 12:31 GMT
>VC 2003 calls f(char const*) for the following code

VS2005 B1 does the same.

Dave
Stefan Slapeta - 18 Mar 2005 13:09 GMT
>>VC 2003 calls f(char const*) for the following code
>
> VS2005 B1 does the same.

Thanks. I've entered Bug FDBK22888.

Stefan
Tom Widmer - 18 Mar 2005 13:40 GMT
> VC 2003 calls f(char const*) for the following code, but it should call
> the function template as f(char const*) is no perfect match (because of
> decay).

I think it's because of the qualification adjustment actually - decay
alone (a form of Lvalue Transformation) would mean that the two were
ambiguous apart from the second being a non-template, so that would win
(change to void f(char*) to see this effect on a conforming compiler).
See 13.3.3.2/3:

"S1 is a proper subsequence of S2 (comparing the conversion sequences in
the canonical form defined by 13.3.3.1.1, excluding any Lvalue
Transformation; the identity conversion sequence is considered to be a
subsequence of any non-identity conversion sequence)"

> Please could someone analyze the behaviour in VC .2005?

Pass, sorry about the unnecessary correction!

Tom
Stefan Slapeta - 21 Mar 2005 12:08 GMT
> I think it's because of the qualification adjustment actually - decay
> alone (a form of Lvalue Transformation) would mean that the two were
[quoted text clipped - 6 lines]
> Transformation; the identity conversion sequence is considered to be a
> subsequence of any non-identity conversion sequence)"

you are perfectly right - very interesting: if you replace char[] by
char*, the template is called! (that's what confused me when I wrote this).

Stefan

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.