Topic: type-id


Author: parthaspanda22@gmail.com
Date: Wed, 14 Nov 2007 13:03:30 CST
Raw View
Although the grammar allows a type to be defined in a type-id,
most C++ compilers reject it. Therefore, the following
doesnt pass:

    struct T;

    struct T *tptr = new (
                                 struct T {
                                     int i;
                                 }
                                );

Can anyone to point to the clause the forbids types from being
defined in a type-id?

Sincerely.

---
[ 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                      ]





Author: Alberto Ganesh Barbati <AlbertoBarbati@libero.it>
Date: Wed, 14 Nov 2007 18:50:01 CST
Raw View
parthaspanda22@gmail.com ha scritto:
> Although the grammar allows a type to be defined in a type-id,
> most C++ compilers reject it. Therefore, the following
> doesnt pass:
>
>     struct T;
>
>     struct T *tptr = new (
>                                  struct T {
>                                      int i;
>                                  }
>                                 );
>
> Can anyone to point to the clause the forbids types from being
> defined in a type-id?
>

5.2.8/4: "Types shall not be defined in the type-id."

Ganesh

---
[ 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                      ]





Author: parthaspanda22@gmail.com
Date: Thu, 15 Nov 2007 08:31:08 CST
Raw View
>
> 5.2.8/4: "Types shall not be defined in the type-id."

But thats specific to the type-id used in Type Identification, isnt
it?

Thats why it is worded as "... the type-id".

type-id is also used with the cast operators, sizeof, new,
exception-specification.

In the section related to exception-specification, I find:

"Types shall not be defined in exception-specifications.".

The std is silent on types defined in type-ids.

Sincerely.





---
[ 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                      ]





Author: Jerry Coffin <jcoffin@taeus.com>
Date: Sun, 18 Nov 2007 15:39:42 CST
Raw View
In article <1195052800.425781.136540@i38g2000prf.googlegroups.com>,
parthaspanda22@gmail.com says...
> Although the grammar allows a type to be defined in a type-id,
> most C++ compilers reject it. Therefore, the following
> doesnt pass:
>
>     struct T;
>
>     struct T *tptr = new (
>                                  struct T {
>                                      int i;
>                                  }
>                                 );
>
> Can anyone to point to the clause the forbids types from being
> defined in a type-id?

5.3.4/4: "The type-specifier-seq shall not contain class declarations,
or enumeration declarations."

--
    Later,
    Jerry.

The universe is a figment of its own imagination.

---
[ 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                      ]