Thread View: comp.std.c++
6 messages
6 total messages
Started by Pochi NORIMATSU
Mon, 14 Dec 1992 07:13
Ambiguity in member pointer declaration
Author: Pochi NORIMATSU
Date: Mon, 14 Dec 1992 07:13
Date: Mon, 14 Dec 1992 07:13
25 lines
1199 bytes
1199 bytes
Sorry if this is on a FAQ list.
Assuming X, Y and Z are class names, how should
X::Y::Z::*foo;
be interpreted?
1. foo is a pointer to member of class ::Y::Z of type X.
('X' is a decl-specifier and '::Y::Z::*foo' is a declarator)
2. foo is a pointer to member of class ::Z of type X::Y.
('X::Y' is a decl-specifier and '::Z::*foo' is a declarator)
3. X::Y::Z is a decl-specifier and ::*mptr is an error.
IMHO, correct interpretation should be 3, but I'm not sure.
Please E-mail me and I'll post a summary.
Thanks in advance!
--
Yasutoshi (Pochi) Norimatsu | Never worry about theory as long as
pnori@lsi-j.co.jp | the machinery does what it's supposed
LSI Japan Co. Ltd., Tokyo, JAPAN | to do. -- R. A. Heinlein
Re: Ambiguity in member pointer declaration
Author: Jerry Schwarz
Date: Tue, 15 Dec 1992 01:13
Date: Tue, 15 Dec 1992 01:13
32 lines
1580 bytes
1580 bytes
|>
|> Assuming X, Y and Z are class names, how should
|>
|> X::Y::Z::*foo;
|>
|> be interpreted?
|>
|> 1. foo is a pointer to member of class ::Y::Z of type X.
|> ('X' is a decl-specifier and '::Y::Z::*foo' is a declarator)
|>
|> 2. foo is a pointer to member of class ::Z of type X::Y.
|> ('X::Y' is a decl-specifier and '::Z::*foo' is a declarator)
|>
|> 3. X::Y::Z is a decl-specifier and ::*mptr is an error.
|>
The is a simpler potential ambiguity lurking in the use of "::" in declarations.
X::f() { ... }
Is the a declaration of "X::f" (implicitly returning int), or of "::f"
(returning X). To avoid this ambiguity there is a rule that a declarator
may not begin with "::". Actually there isn't a rule per se. The grammar
doesn't contain any rules that derive a declarator starting with "::".
And that omission is deliberate.
So answer to the question is that non of the above interpretations
is possible. X::Y::Z::*foo, is a declartor and since no explicit
typespec is present int is assumed. This means that you declaring
"foo" as a pointer to int member of X::Y::Z.
-- Jerry Schwarz.
Re: Ambiguity in member pointer declaration
Author: Pochi NORIMATSU
Date: Wed, 16 Dec 1992 04:21
Date: Wed, 16 Dec 1992 04:21
17 lines
1291 bytes
1291 bytes
In article <1992Dec15.011359.17235@lucid.com> jss@lucid.com (Jerry Schwarz) writes: [stuff deleted] > The grammar > doesn't contain any rules that derive a declarator starting with "::". > And that omission is deliberate. But in ARM section 8.2.3, it says that the declarator representing a pointer to members has the form complete-class-name :: * cv-qualifier-list<opt> D1 And complete-class-name can start with ::. Or is it typo? -- Yasutoshi (Pochi) Norimatsu | Never worry about theory as long as pnori@lsi-j.co.jp | the machinery does what it's supposed LSI Japan Co. Ltd., Tokyo, JAPAN | to do. -- R. A. Heinlein
Re: Ambiguity in member pointer declaration
Author: Jerry Schwarz
Date: Wed, 16 Dec 1992 21:16
Date: Wed, 16 Dec 1992 21:16
24 lines
1396 bytes
1396 bytes
In article <PNORI.92Dec16132118@hyperion.lsi-j.co.jp>, pnori@lsi-j.co.jp (Pochi NORIMATSU) writes: |> In article <1992Dec15.011359.17235@lucid.com> jss@lucid.com (Jerry Schwarz) writes: jss: |> > The grammar |> > doesn't contain any rules that derive a declarator starting with "::". |> > And that omission is deliberate. pnori: |> But in ARM section 8.2.3, it says that the declarator representing a |> pointer to members has the form |> |> complete-class-name :: * cv-qualifier-list<opt> D1 |> |> And complete-class-name can start with ::. Or is it typo? pnori is right. This grammar path does lead to a declarator that begins with a "::". I suspect this is an oversight. Since, as the original item pointed out, it also leads to an ambiguity it is something the standards committee should address. I think it should be made illegal on the grounds of my original comment. -- Jerry Schwarz
Re: Ambiguity in member pointer declaration
Author: Marc Girod
Date: Fri, 18 Dec 1992 12:27
Date: Fri, 18 Dec 1992 12:27
39 lines
2106 bytes
2106 bytes
>>>>> On 16 Dec 92 04:21:18 GMT, pnori@lsi-j.co.jp (Pochi NORIMATSU) said: pnori> In article <1992Dec15.011359.17235@lucid.com> jss@lucid.com (Jerry Schwarz) writes: jss> The grammar jss> doesn't contain any rules that derive a declarator starting with "::". jss> And that omission is deliberate. pnori> But in ARM section 8.2.3, it says that the declarator representing a pnori> pointer to members has the form pnori> complete-class-name :: * cv-qualifier-list<opt> D1 pnori> And complete-class-name can start with ::. Or is it typo? Do you have a version of the ARM different than mine (1990, ISBN 0-201-51459-1...)? In my book it reads in section 8.2.3, p 135: class-name :: * cv-qualifier-list<opt> D1 and class-name is just identifier (17.1 p 387) when (p 392) complete-class-name: qualified-class-name :: qualified-class-name and qualified-class-name: typedef-name class-name :: qualified-class-name -- +-----------------------------------------------------------------------------+ | Marc Girod - Nokia Telecommunications Phone: +358-0-511 7703 | | TL4E - P.O. Box 12 Fax: +358-0-511 7432 | | SF-02611 Espoo 61 - Finland Internet: marc.girod@ntc.nokia.com | | X.400: C=FI, A=Elisa, P=Nokia Telecom, UNIT=TRS, SUR=Girod, GIV=Marc | +-----------------------------------------------------------------------------+
Re: Ambiguity in member pointer declaration
Author: Pochi NORIMATSU
Date: Mon, 21 Dec 1992 07:04
Date: Mon, 21 Dec 1992 07:04
23 lines
1696 bytes
1696 bytes
In article <GIROD.92Dec18142728@node_262d6.tele.nokia.fi> girod@tele.nokia.fi (Marc Girod) writes: > Do you have a version of the ARM different than mine (1990, > ISBN 0-201-51459-1...)? > > In my book it reads in section 8.2.3, p 135: > > class-name :: * cv-qualifier-list<opt> D1 > > and class-name is just identifier (17.1 p 387) I have two ARMs :-) One is the same book as you have, and another is "Reprinted with corrections May, 1992" version. In the reprinted book, class-name has been replaced by complete-class-name. BTW, the definition of ptr-operator in section 17.4 in the older book is also says that a pointer to members starts with complete-class-name. Don't you think its confusing? -- Yasutoshi (Pochi) Norimatsu | Never worry about theory as long as pnori@lsi-j.co.jp | the machinery does what it's supposed LSI Japan Co. Ltd., Tokyo, JAPAN | to do. -- R. A. Heinlein
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads