This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/17150] Ugly diagnostics for invalid variably modified type


------- Additional Comments From gdr at gcc dot gnu dot org  2004-08-29 15:31 -------
(In reply to comment #0)
> This test case posted for PR 17148:
> 
> struct A {};
> struct B : A
> {
>     static int foo() { return 1; }
>     int i[B::foo()];
> };
> 
> produces the ugly diagnostic:
> 
> test.cc:6: error: data member may not have variably modified type `int [(((long
> unsigned int)(((long int)B::foo()) - 1)) + 1u)]'

This stupid pretty printing comes from the way GCC currently handles arrays.
When you declare an array 

     T i[N];

GCC represents the index values as a range type 0...(N-1), hence the curious
-1.  Latter, when pretty printing, we try to recover that off-one thingy, hence
the curious +1.  The unsignedness come from one more GCC artefact.
Notice that fold() is unable to smash that nonsense down to the trivial thing.
A way out of this mess is to stop fiddling with what user writes and define
normal forms for expressions, with some ordering.

-- Gaby


> 
> with g++ 3.5.0 20040815 on alphaev68-unknown-linux-gnu.



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17150


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]