From -5833906413952662829
X-Google-Thread: f78e5,79ca29fdef991a75
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII
Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.speakeasy.net!news.speakeasy.net.POSTED!not-for-mail
NNTP-Posting-Date: Wed, 21 Mar 2007 18:40:11 -0500
Return-Path: <devnull@stump.algebra.com>
X-Authentication-Warning: mulga.csse.unimelb.edu.au: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Original-To: std-c++@mailman.ucar.edu
Delivered-To: std-c++@mailman.ucar.edu
From: "=?iso-8859-1?q?Daniel_Kr=FCgler?=" <daniel.kruegler@googlemail.com>
Newsgroups: comp.std.c++
Subject: Re: Address of member in class scope
Organization: http://groups.google.com
Message-ID: <1174519543.189471.264180@p15g2000hsd.googlegroups.com>
References: <1174158249.879833.103950@p15g2000hsd.googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
X-Complaints-To: groups-abuse@google.com
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: p15g2000hsd.googlegroups.com; posting-host=89.48.253.49;
   posting-account=0YhmiQ0AAABRDjD_6coNmBVB3rgPlaOq
X-Virus-Scanned: amavisd-new at ucar.edu
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by mulga.csse.unimelb.edu.au id l2LNQ0bi021332
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
Date: Wed, 21 Mar 2007 18:34:34 CST
Lines: 52
NNTP-Posting-Host: 65.182.171.162
X-Trace: sv3-hihJRuZe3f4drSOEvW42YYsIvsLH4mCA8Qlnzea7P0RhqymmNpSvLsE/FVfz5aRHzLIx/slkBsCrdn+!C/osk+Ry8EJ82eedOEOrNUeNWmtCUKeA9YUpXkBY2keSXVfceADYEb0Oh0sXDI7v/6TRAJEuAc8F!p7UZ09WuLpL5+76jmXPOGBYg2cEp5edtFZxvj6sAjvo=
X-Complaints-To: abuse@speakeasy.net
X-DMCA-Complaints-To: abuse@speakeasy.net
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.34
Xref: g2news1.google.com comp.std.c++:8166


marwan.taher@gmail.com schrieb:

> Can someone tell me why the following code won't compile? I am taking
> the address of a class member within the class's declaration. This
> works for a pointer to member function, but fails for a pointer to
> data member. Is my compiler at fault? Or does the standard explicitly
> forbid this?

The standard does not explicitely forbid that. IMO the code
(commented or uncommented) is fine, therefore using
3.3.1/4 as reference, which says

"After the point of declaration of a class member, the member name
can be looked up in the scope of its class. [Note: this is true even
if
the class is an incomplete class. For example,
struct X {
enum E { z = 16 };
int b[X::z]; // OK
};
-end note]"

Additionally I also see no reasons why your example
should violate anyone of the requirements described
in 3.3.6 ([basic.scope.class]), especially not for

2) "A name N used in a class S shall refer to the same declaration
in its context and when re-evaluated in the completed scope of S.
No diagnostic is required for a violation of this rule."

or

3) "If reordering member declarations in a class yields an alternate
valid program under (1) and (2), the program is ill-formed, no
diagnostic is required."

I also observed that existing implementations differ here. E.g.
both Comeau and mingw 3.4 accept the code, but VS2005-SP1
rejects it (I guess you have tested the last one?).

Greetings from Bremen,

Daniel Kr�gler


---
[ 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.comeaucomputing.com/csc/faq.html                      ]



