Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ADL: should this compile?

64 views
Skip to first unread message

Jason McKesson

unread,
Apr 22, 2012, 2:52:41 PM4/22/12
to
GCC version 4.7 seems to have fixed a bug
(http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29131), but I'm wondering
if it caused another.

Should this C++ code compile? I think ADL requires it to, but I'm not certain.

template<class T>
int t(T i)
{
return f(i);
}

struct a{};

int f(a i)
{
return 0;
}

int main()
{
a b;
return t(b);
}


--
[ comp.std.c++ is moderated. To submit articles, try posting with your ]
[ newsreader. If that fails, use mailto:std-cpp...@vandevoorde.com ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]

Daniel Krügler

unread,
Apr 22, 2012, 4:52:49 PM4/22/12
to
Am 22.04.2012 20:52, schrieb Jason McKesson:
[..]
> Should this C++ code compile? I think ADL requires it to, but I'm not certain.
>
> template<class T>
> int t(T i)
> {
> return f(i);
> }
>
> struct a{};
>
> int f(a i)
> {
> return 0;
> }
>
> int main()
> {
> a b;
> return t(b);
> }

Yes, this clearly is supposed to work according to ADL rules. All recent
compilers I know of (including gcc 4.8) accept this example as they should.

HTH& Greetings from Bremen,

Daniel Krügler
0 new messages