 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Christopher Yeleighton Guest
|
Posted: Fri Dec 30, 2005 6:21 pm Post subject: Defect Report: 8.3.1/1, 8.3.4/1: description ignores precede |
|
|
[ Moderator's note: Forwarded to C++ committee. -sdc ]
1. Consider the declaration "char *arr[01]". Take "char" for T, "*arr[01]"
for D.
1.1. Take "arr[01]" for D1 to match the assumptions. T D1 resolves to "char
arr[01]" and the type of identifier "arr" in T D1 is "array of 1 char"
according to 8.3.4/1. Therefore the type of identifier "arr" is "
array of 1 pointer to char". This is counterintuitive: an array is defined
in the section "Meaning of pointers".
1.2. Take "*arr" for D1. T D1 resolves to "char *arr" and the type of
identifier "arr" in T D1 is "pointer to char". 8.3.4/1 implies that the
type of identifier "arr" is "pointer to array of 1 char" and that it denotes
an array at the same time. Internal contradiction and contradiction to the
deduction of 1.1. It should be mentioned that in "D1[01]" does not match
"D" in this setting.
The statement of 8.3/6: "Parentheses can alter the binding of complex
declarators" is meaningless because the term "binding" is undefined in this
context.
[ 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 ]
|
|
| Back to top |
|
 |
Krzysztof Zelechowski Guest
|
Posted: Tue Jan 24, 2006 3:58 pm Post subject: Re: Defect Report: 8.3.1/1, 8.3.4/1: description ignores pre |
|
|
Uzytkownik <william.m.miller (AT) gmail (DOT) com> napisal w wiadomosci
news:1136911161.022856.286780 (AT) z14g2000cwz (DOT) googlegroups.com...
| Quote: | Christopher Yeleighton wrote:
[ Moderator's note: Forwarded to C++ committee. -sdc ]
1. Consider the declaration "char *arr[01]". Take "char" for T,
"*arr[01]"
for D.
1.1. Take "arr[01]" for D1 to match the assumptions. T D1 resolves to
"char
arr[01]" and the type of identifier "arr" in T D1 is "array of 1 char"
according to 8.3.4/1. Therefore the type of identifier "arr" is "
array of 1 pointer to char". This is counterintuitive: an array is
defined
in the section "Meaning of pointers".
1.2. Take "*arr" for D1. T D1 resolves to "char *arr" and the type of
identifier "arr" in T D1 is "pointer to char". 8.3.4/1 implies that the
type of identifier "arr" is "pointer to array of 1 char" and that it
denotes
an array at the same time. Internal contradiction and contradiction to
the
deduction of 1.1. It should be mentioned that in "D1[01]" does not match
"D" in this setting.
The statement of 8.3/6: "Parentheses can alter the binding of complex
declarators" is meaningless because the term "binding" is undefined in
this
context.
The C++ Standard describes the binding/precedence of both
expressions and declarators via the syntactic productions. To
grasp how the specifications in the subsections of 8.3 are to be
understood and applied, you have to start with the grammar of
declarators at the beginning of clause 8. The syntax of
declarator is:
declarator:
direct-declarator
ptr-operator declarator
|
The problem is that 8.3.4 is not explicit that D1 must denote a direct
declarator. Literal reading gives you the impression that D1 can be just
anything.
Chris
---
[ 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 ]
|
|
| Back to top |
|
 |
Krzysztof Zelechowski Guest
|
Posted: Tue Jan 24, 2006 5:58 pm Post subject: Re: Defect Report: 8.3.1/1, 8.3.4/1: description ignores pre |
|
|
Thank you, your answer is comprehensive and exhaustive. Almost everything
is clear now except that did not address the issue that an array is being
defined in the section "Meaning of pointers". Perhaps the section title
should be changed because a pointer is a semantic entity, not a syntactic
one, and I would not look for a recipe how to declare an array in this
section.
Chris
Uzytkownik <william.m.miller (AT) gmail (DOT) com> napisal w wiadomosci
news:1136911161.022856.286780 (AT) z14g2000cwz (DOT) googlegroups.com...
| Quote: | Christopher Yeleighton wrote:
[ Moderator's note: Forwarded to C++ committee. -sdc ]
1. Consider the declaration "char *arr[01]". Take "char" for T,
"*arr[01]"
for D.
1.1. Take "arr[01]" for D1 to match the assumptions. T D1 resolves to
"char
arr[01]" and the type of identifier "arr" in T D1 is "array of 1 char"
according to 8.3.4/1. Therefore the type of identifier "arr" is "
array of 1 pointer to char". This is counterintuitive: an array is
defined
in the section "Meaning of pointers".
1.2. Take "*arr" for D1. T D1 resolves to "char *arr" and the type of
identifier "arr" in T D1 is "pointer to char". 8.3.4/1 implies that the
type of identifier "arr" is "pointer to array of 1 char" and that it
denotes
an array at the same time. Internal contradiction and contradiction to
the
deduction of 1.1. It should be mentioned that in "D1[01]" does not match
"D" in this setting.
The statement of 8.3/6: "Parentheses can alter the binding of complex
declarators" is meaningless because the term "binding" is undefined in
this
context.
The term "binding" is used in its ordinary sense of associating
various syntactic elements with each other during parsing, i.e.,
turning a linear sequence of tokens into a hierarchical syntax
tree. For example, in expressions "*" binds more tightly, i.e., has
a higher precedence, than "+". Thus, in an expression like a+b*c,
the binding is "a plus the product of b and c." Just as in
declarators, parentheses can change the binding, so that (a+b)*c
means "the sum of a and b, times c." This usage is common
enough that I do not believe it is a defect for it not to be defined
here.
The C++ Standard describes the binding/precedence of both
expressions and declarators via the syntactic productions. To
grasp how the specifications in the subsections of 8.3 are to be
understood and applied, you have to start with the grammar of
declarators at the beginning of clause 8. The syntax of
declarator is:
declarator:
direct-declarator
ptr-operator declarator
The nonterminal direct-declarator is where the function and array
declarator operators are applied. What this means is that the
function and array operators bind more tightly than the pointer
operators -- that is, you only apply pointer operators to a
declarator that is a direct-declarator, already containing the
array or function operators.
|
---
[ 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 ]
|
|
| Back to top |
|
 |
william.m.miller@gmail.co Guest
|
Posted: Thu Jan 26, 2006 5:35 am Post subject: Re: Defect Report: 8.3.1/1, 8.3.4/1: description ignores pre |
|
|
"Krzysztof Zelechowski" wrote:
| Quote: | Thank you, your answer is comprehensive and exhaustive. Almost everything
is clear now except that did not address the issue that an array is being
defined in the section "Meaning of pointers". Perhaps the section title
should be changed because a pointer is a semantic entity, not a syntactic
one, and I would not look for a recipe how to declare an array in this
section.
|
And you will not find it there, either. Each of the subsections of
8.3 deals with a single level in the recursive tree-walk. In your
example, when you are in 8.3.1, you are declaring a pointer to
whatever declarator was processed at the next level down in the
syntax tree. In this case, it's a pointer to an array. However,
8.3.1 deals only with the "pointer" part. The "array" part was
dealt with at the appropriate level of the tree by 8.3.4.
You seem to be expecting each subsection of 8.3 to deal with
the entire declarator, not just one level of the tree, and that's
just not true. To process your example, you will use _both_
8.3.1 _and_ 8.3.4; there's no concept of "array" in 8.3.1.
-- William M. (Mike) Miller
Edison Design Group
---
[ 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 ]
|
|
| Back to top |
|
 |
Krzysztof Zelechowski Guest
|
Posted: Fri Jan 27, 2006 3:35 pm Post subject: Re: Defect Report: 8.3.1/1, 8.3.4/1: description ignores pre |
|
|
Uzytkownik <william.m.miller (AT) gmail (DOT) com> napisal w wiadomosci
news:1138217361.291010.186680 (AT) g49g2000cwa (DOT) googlegroups.com...
| Quote: | "Krzysztof Zelechowski" wrote:
Thank you, your answer is comprehensive and exhaustive. Almost
everything
is clear now except that did not address the issue that an array is being
defined in the section "Meaning of pointers". Perhaps the section title
should be changed because a pointer is a semantic entity, not a syntactic
one, and I would not look for a recipe how to declare an array in this
section.
And you will not find it there, either. Each of the subsections of
8.3 deals with a single level in the recursive tree-walk. In your
example, when you are in 8.3.1, you are declaring a pointer to
whatever declarator was processed at the next level down in the
syntax tree. In this case, it's a pointer to an array. However,
8.3.1 deals only with the "pointer" part. The "array" part was
dealt with at the appropriate level of the tree by 8.3.4.
|
No sir, it is an array of pointers. You have put it wrong yourself. That
is just my point.
In order to identify the semantics of a structure we have to traverse a
tree. If the root node is labeled "Meaning of X", we can be sure that
whatever follows constitutes ultimately an X, provided that X is a semantic
entity and not a syntactic entity. The description T *D1 suggests that it
is the root node and the child node is labeled D1[01]. It gives us the
false impression that we the char *arr[01] is a pointer. It is not.
Conclusion: the label is misleading. Resolution: change the label to
"Meaning of asterisks".
Chris
---
[ 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 ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|