Topic: Ambiguity in member pointer declaration


Author: pnori@lsi-j.co.jp (Pochi NORIMATSU)
Date: 21 Dec 92 07:04:55 GMT
Raw View
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




Author: pnori@lsi-j.co.jp (Pochi NORIMATSU)
Date: 16 Dec 92 04:21:18 GMT
Raw View
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




Author: jss@lucid.com (Jerry Schwarz)
Date: Wed, 16 Dec 92 21:16:48 GMT
Raw View
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




Author: girod@tele.nokia.fi (Marc Girod)
Date: Fri, 18 Dec 1992 12:27:28 GMT
Raw View
>>>>> 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     |
+-----------------------------------------------------------------------------+




Author: pnori@lsi-j.co.jp (Pochi NORIMATSU)
Date: 14 Dec 92 07:13:01 GMT
Raw View
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




Author: jss@lucid.com (Jerry Schwarz)
Date: Tue, 15 Dec 92 01:13:59 GMT
Raw View
|>
|> 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.