Topic: What does the standard say about this?
Author: "Evan D." <evaned@gmail.com>
Date: Sat, 16 Jul 2011 15:26:35 CST Raw View
[Cross post to comp.lang.c++, but I posted it there a while back and
haven't had any responses. This may be a better newsgroup for it
anyway.]
I have some code that I don't understand the implications of. GCC
4.6.1 (and the earlier versions I've tried) accept it, but EDG does
not (specifically, I've tried with Comeau's online front end and
Intel
CC 11.0).
I'm quite familiar with some of the weird name lookup issues that
arise when templates and dependent names are involved, but at least
I
would argue that they shouldn't apply in this case. Is it a defect
in
EDG that it rejects it, a defect in GCC that accepts it, or one of
those places where the code isn't compliant but compliers aren't
required to issue a diagnostic?
EDG reports:
error: declaration is incompatible with
"ref_ptr<Wrapper<T>::control>
Wrapper<T>::control::alpha()" (declared
at line 9)
Wrapper<T>::control::alpha()
in this code:
template< typename T >
class ref_ptr {
};
template <typename T>
class Wrapper {
class control {
public:
static ref_ptr<control> alpha();
};
typedef ref_ptr<control> controlRefPtr;
};
template <typename T>
typename Wrapper<T>::controlRefPtr
Wrapper<T>::control::alpha()
{
}
--
[ comp.std.c++ is moderated. To submit articles, try posting with your ]
[ newsreader. If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: =?ISO-8859-1?Q?Daniel_Kr=FCgler?= <daniel.kruegler@googlemail.com>
Date: Sun, 17 Jul 2011 09:51:12 CST Raw View
Am 16.07.2011 23:26, schrieb Evan D.:
>
> [Cross post to comp.lang.c++, but I posted it there a while back and
> haven't had any responses. This may be a better newsgroup for it
> anyway.]
>
> I have some code that I don't understand the implications of. GCC
> 4.6.1 (and the earlier versions I've tried) accept it, but EDG does
> not (specifically, I've tried with Comeau's online front end and
> Intel
> CC 11.0).
>
> I'm quite familiar with some of the weird name lookup issues that
> arise when templates and dependent names are involved, but at least
> I
> would argue that they shouldn't apply in this case. Is it a defect
> in
> EDG that it rejects it, a defect in GCC that accepts it, or one of
> those places where the code isn't compliant but compliers aren't
> required to issue a diagnostic?
>
> EDG reports:
> error: declaration is incompatible with
> "ref_ptr<Wrapper<T>::control>
> Wrapper<T>::control::alpha()" (declared
> at line 9)
> Wrapper<T>::control::alpha()
>
> in this code:
> template< typename T>
> class ref_ptr {
> };
>
> template<typename T>
> class Wrapper {
> class control {
> public:
> static ref_ptr<control> alpha();
> };
> typedef ref_ptr<control> controlRefPtr;
> };
>
> template<typename T>
> typename Wrapper<T>::controlRefPtr
> Wrapper<T>::control::alpha()
> {
> }
This example looks like a variant of the open core issue
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#2
to me. Following the current non-normative state of the issue, I would
argue that your example is correctly diagnosed as ill-formed, because
the meaning of Wrapper<T>::controlRefPtr depends on the concrete
instantiation of Wrapper<T>.
HTH & Greetings from Bremen,
Daniel Kr gler
--
[ comp.std.c++ is moderated. To submit articles, try posting with your ]
[ newsreader. If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]