Re: (int)"text" as initializer
- From: "Jun Woong" <woong@xxxxxxxxx>
- Date: Sun, 27 Nov 2005 03:55:51 +0900
"Antoine Leca" <root@xxxxxxxxxxxxxxxxx> wrote in message news:4386e6ae$0$19915$626a54ce@xxxxxxxxxxxxxxx
> En news:1132907856.135044.202250@xxxxxxxxxxxxxxxxxxxxxxxxxxxx,
> the cancer va escriure:
> >
> > struct s {int a;} s = {(int)"test"};
> >
>
[...]
>
> My question is, is a compiler allowed to _reject_ it?
>
Yes, I think so. The interpretation you showed in your previous
posting seems to be correct to me. I doubt that the committee
(actually, the wording in question was written by Clive, as I recall
correctly) intentionally dropped that form, but in the current state
there is no way to say an implementation which rejects it is not
conforming.
And it is verly likely for the committee to reject a DR to request
addition of (int)"test" to the arithmetic constant expression, because
a s.c. program ('s output) can't depend on it anyway.
One interesting thing here is whether or not an implementation like
gcc 3.4 documents that "(int)"test"" constitutes an implementation-
defined form of the arithmetic constant expression. ;-)
[from your previous posting]
> const int t = (int)"text"; /* silently compiled */
>
> struct s {int a;} s = {(int)"text"}; /* rejected
> 'coz <<initializer must be constant>> */
I think this is also possible. Once it is subject to an implementation
-defined constant expression, an implementation is free to accept the
former rejecting the latter, as long as it documents it consistently.
--
Jun, Woong (woong at icu.ac.kr)
Information and Communications Univ.
.
- References:
- (int)"text" as initializer
- From: Antoine Leca
- Re: (int)"text" as initializer
- From: the cancer
- Re: (int)"text" as initializer
- From: Antoine Leca
- (int)"text" as initializer
- Prev by Date: Re: Trigraphs
- Next by Date: [JW] alignment problem for structures
- Previous by thread: Re: (int)"text" as initializer
- Next by thread: Re: (int)"text" as initializer
- Index(es):
Relevant Pages
|
Loading