Topic: Attribute-specifier ambiguity with other syntactical constructions.
Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Mon, 11 Feb 2013 08:31:27 -0800 (PST)
Raw View
------=_Part_37_16556368.1360600287184
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
I think that paragraph #6 of section 7.6.1 Attribute syntax and semantics=
=20
shall include a mention about an error message =20
6 Two consecutive left square bracket tokens shall appear only when=20
> introducing an attribute-speci=EF=AC=81er. [ Note:
> If two consecutive left square brackets appear where an attribute-speci=
=EF=AC=81er=20
> is not allowed, the program is ill formed even if the brackets match an=
=20
> alternative grammar production. =E2=80=94 end note ] [Example:
> int p[10];
> void f() {
> int x =3D 42, y[5];
> int(p[[x] { return x; }()]); // error: malformed attribute on a nested
> // declarator-id and not a function-style cast of
> // an element of p.
> y[[] { return 2; }()] =3D 2; // error even though attributes are not allo=
wed
> // in this context.
> }
> =E2=80=94 end example ]
I tried the following example
#include <iostream>
int main(){
const char *s =3D "Hello";
=20
std::cout << s[[]{ return 1; }()] << std::endl;
=20
return 0;}
and most compilers compile the code without any warning. I think that it is=
not enough simply to say that the program is ill-formed. I think that the =
compiler shall issue an error message because it is very difficult to find =
such ambiguity with the attribute-specifiers in code.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/?hl=3Den.
------=_Part_37_16556368.1360600287184
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
I think that paragraph #6 of section 7.6.1 Attribute syntax and semant=
ics shall include a mention about an error message <br><div><br></div=
><div><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex;=
border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left=
-style: solid; padding-left: 1ex;">6 Two consecutive left square bracket to=
kens shall appear only when introducing an attribute-speci=EF=AC=81er. [ No=
te:<br>If two consecutive left square brackets appear where an attribute-sp=
eci=EF=AC=81er is not allowed, the program is ill formed even if the b=
rackets match an alternative grammar production. =E2=80=94 end note ] [Exam=
ple:<br>int p[10];<br>void f() {<br>int x =3D 42, y[5];<br>int(p[[x] { retu=
rn x; }()]); // error: malformed attribute on a nested<br>// declarator-id =
and not a function-style cast of<br>// an element of p.<br>y[[] { return 2;=
}()] =3D 2; // error even though attributes are not allowed<br>// in this =
context.<br>}<br>=E2=80=94 end example ]</blockquote></div><div><br></div><=
div>I tried the following example</div><div><br></div><div><pre class=3D"de=
1" style=3D"padding-bottom: 5px; padding-top: 3px; padding-left: 10px; colo=
r: rgb(0, 0, 102); background-color: rgb(250, 250, 250);"><br><pre class=3D=
"de1" style=3D"padding-bottom: 5px; padding-top: 3px; padding-left: 10px;">=
<span class=3D"co2" style=3D"line-height: 13px !important; color: rgb(51, 1=
53, 0);">#include <iostream></span>
<span class=3D"kw4" style=3D"line-height: 13px !important; color: rgb(0, 0,=
255);">int</span> main<span class=3D"br0" style=3D"line-height: 13px !impo=
rtant; color: rgb(0, 128, 0);">(</span><span class=3D"br0" style=3D"line-he=
ight: 13px !important; color: rgb(0, 128, 0);">)</span>
<span class=3D"br0" style=3D"line-height: 13px !important; color: rgb(0, 12=
8, 0);">{</span>
<span class=3D"kw4" style=3D"line-height: 13px !important; co=
lor: rgb(0, 0, 255);">const</span> <span class=3D"kw4" style=3D"line-height=
: 13px !important; color: rgb(0, 0, 255);">char</span> <span class=3D"sy2" =
style=3D"line-height: 13px !important; color: rgb(0, 0, 64);">*</span>s <sp=
an class=3D"sy1" style=3D"line-height: 13px !important; color: rgb(0, 0, 12=
8);">=3D</span> <span class=3D"st0" style=3D"line-height: 13px !important; =
color: rgb(255, 0, 0);">"Hello"</span><span class=3D"sy4" style=3D"line-hei=
ght: 13px !important; color: rgb(0, 128, 128);">;</span>
=20
std<span class=3D"sy4" style=3D"line-height: 13px !important;=
color: rgb(0, 128, 128);">::</span><span class=3D"kw3" style=3D"line-heigh=
t: 13px !important; color: rgb(0, 0, 221);">cout</span> <span class=3D"sy1"=
style=3D"line-height: 13px !important; color: rgb(0, 0, 128);"><<</s=
pan> s<span class=3D"br0" style=3D"line-height: 13px !important; color: rgb=
(0, 128, 0);">[</span><span class=3D"br0" style=3D"line-height: 13px !impor=
tant; color: rgb(0, 128, 0);">[</span><span class=3D"br0" style=3D"line-hei=
ght: 13px !important; color: rgb(0, 128, 0);">]</span><span class=3D"br0" s=
tyle=3D"line-height: 13px !important; color: rgb(0, 128, 0);">{</span> <spa=
n class=3D"kw1" style=3D"line-height: 13px !important; color: rgb(0, 0, 255=
);">return</span> <span class=3D"nu0" style=3D"line-height: 13px !important=
; color: rgb(0, 0, 221);">1</span><span class=3D"sy4" style=3D"line-height:=
13px !important; color: rgb(0, 128, 128);">;</span> <span class=3D"br0" st=
yle=3D"line-height: 13px !important; color: rgb(0, 128, 0);">}</span><span =
class=3D"br0" style=3D"line-height: 13px !important; color: rgb(0, 128, 0);=
">(</span><span class=3D"br0" style=3D"line-height: 13px !important; color:=
rgb(0, 128, 0);">)</span><span class=3D"br0" style=3D"line-height: 13px !i=
mportant; color: rgb(0, 128, 0);">]</span> <span class=3D"sy1" style=3D"lin=
e-height: 13px !important; color: rgb(0, 0, 128);"><<</span> std<span=
class=3D"sy4" style=3D"line-height: 13px !important; color: rgb(0, 128, 12=
8);">::</span><span class=3D"me2" style=3D"line-height: 13px !important; co=
lor: rgb(0, 119, 136);">endl</span><span class=3D"sy4" style=3D"line-height=
: 13px !important; color: rgb(0, 128, 128);">;</span>
=20
<span class=3D"kw1" style=3D"line-height: 13px !important; co=
lor: rgb(0, 0, 255);">return</span> <span class=3D"nu0" style=3D"line-heigh=
t: 13px !important; color: rgb(0, 0, 221);">0</span><span class=3D"sy4" sty=
le=3D"line-height: 13px !important; color: rgb(0, 128, 128);">;</span>
<span class=3D"br0" style=3D"line-height: 13px !important; color: rgb(0, 12=
8, 0);">}</span></pre></pre><pre class=3D"de1" style=3D"padding-bottom: 5px=
; padding-top: 3px; padding-left: 10px; color: rgb(0, 0, 102); background-c=
olor: rgb(250, 250, 250);"><span class=3D"br0" style=3D"line-height: 13px !=
important; color: rgb(0, 128, 0);"><br></span></pre><pre class=3D"de1" styl=
e=3D"padding-bottom: 5px; padding-top: 3px; padding-left: 10px; color: rgb(=
0, 0, 102); background-color: rgb(250, 250, 250);"><span class=3D"br0" styl=
e=3D"line-height: 13px !important; color: rgb(0, 128, 0);">and most compile=
rs compile the code without any warning. I think that it is not enough simp=
ly to say that the program is ill-formed. I think that the compiler shall i=
ssue an error message because it is very difficult to find such ambiguity w=
ith the attribute-specifiers in code.</span></pre></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_37_16556368.1360600287184--
.