Topic: Is this a Bug in Comeau? (aka befriending classes in anonymous
Author: fvali@kumc.edu ("Faisal Vali")
Date: Wed, 1 Oct 2003 05:50:49 +0000 (UTC) Raw View
(Note to mod: I posted this previously thru google and it did not
appear)
A few weeks ago David Abrahams asked in a post if there was a way to
make the following
code work:
namespace { class M; }
class RD { friend class M; typedef int Q; };
namespace { class M { RD::Q i; }; }
-----
>From my reading of the standard (3.4.4, 3.4.1) the only thing needed
to make the above code work, is a standard compliant compiler (since M
is lookedup by unqualified name lookup which searches thru using
directives in a sense).
I tried the above code with comeau online and it claimed that M did
not have access to RD's privates.
The following did not work either (trying to use Qualified Name lookup
to prevent the auto-declaration 'feature' of friend declarations)
...
class RD { friend class ::M; ... };..
...
I believe the above is standard compliant too - and comeau does not
allow it.
Can someone please clarify these issues - either by quoting the
relevant passages in the std that mandate comeau's behavior or by
agreeing that this is indeed well-formed code and comeau should
compile it.
thanks,
Faisal Vali
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: jhs@edg.com ("John H. Spicer")
Date: Thu, 2 Oct 2003 03:31:21 +0000 (UTC) Raw View
Faisal Vali wrote:
> (Note to mod: I posted this previously thru google and it did not
> appear)
>
> A few weeks ago David Abrahams asked in a post if there was a way to
> make the following
> code work:
>
> namespace { class M; }
>
> class RD { friend class M; typedef int Q; };
>
> namespace { class M { RD::Q i; }; }
>
> -----
>
>>From my reading of the standard (3.4.4, 3.4.1) the only thing needed
> to make the above code work, is a standard compliant compiler (since M
> is lookedup by unqualified name lookup which searches thru using
> directives in a sense).
>
> I tried the above code with comeau online and it claimed that M did
> not have access to RD's privates.
>
> The following did not work either (trying to use Qualified Name lookup
> to prevent the auto-declaration 'feature' of friend declarations)
>
> ...
> class RD { friend class ::M; ... };..
> ...
>
> I believe the above is standard compliant too - and comeau does not
> allow it.
>
> Can someone please clarify these issues - either by quoting the
> relevant passages in the std that mandate comeau's behavior or by
> agreeing that this is indeed well-formed code and comeau should
> compile it.
There is a core language issue (#138) that deals with this issue (and some
others). In the current language, the situation is unclear. The issue is still
open, but I've written a paper that suggests that this case should be well-formed.
John Spicer
Edison Design Group
>
>
> thanks,
> Faisal Vali
>
>
> ---
> [ comp.std.c++ is moderated. To submit articles, try just posting with ]
> [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
> [ --- Please see the FAQ before posting. --- ]
> [ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
>
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: anthony.williamsNOSPAM@anthonyw.cjb.net (Anthony Williams)
Date: Thu, 2 Oct 2003 22:13:50 +0000 (UTC) Raw View
fvali@kumc.edu ("Faisal Vali") writes:
> A few weeks ago David Abrahams asked in a post if there was a way to
> make the following
> code work:
>
> namespace { class M; }
>
> class RD { friend class M; typedef int Q; };
>
> namespace { class M { RD::Q i; }; }
>
> -----
>
>>From my reading of the standard (3.4.4, 3.4.1) the only thing needed
> to make the above code work, is a standard compliant compiler (since M
> is lookedup by unqualified name lookup which searches thru using
> directives in a sense).
My reading of 11.4p7 is that M should be a friend of RD, since it the name M
is accessible in the scope of RD.
> I tried the above code with comeau online and it claimed that M did
> not have access to RD's privates.
>
> The following did not work either (trying to use Qualified Name lookup
> to prevent the auto-declaration 'feature' of friend declarations)
>
> ...
> class RD { friend class ::M; ... };..
> ...
>
> I believe the above is standard compliant too - and comeau does not
> allow it.
This won't work, since the qualified name of M is not knowable; this declares
that a class M in the global namespace, rather than the unnamed namespace, is
a friend.
Anthony
--
Anthony Williams
Senior Software Engineer, Beran Instruments Ltd.
Remove NOSPAM when replying, for timely response.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]