Expr constructor question

Weihaw Chuang weihawchuang@hotmail.com
Tue Mar 9 23:38:00 GMT 2004


Hi all,
Hopefully this is the right mailing list for discussions about GCC 
internals.  My end goal is to modify the Greg McGary's bounds checker, but 
in the following I just want to figure out "struct" initialization.

At the highest level, can someone tell me why the following is causes an 
error:
#include <stdio.h>
struct record {
    int a;
};

struct record object;
struct record * ptr = &object;
struct record * ptr2 = ptr;        // <============ problem

int main()
{
    printf("done");}

>gcc rec2.c -S
rec2.c:8: initializer element is not constant
If I remove the problem line, then the compiler message goes away.  Now 
putting aside C rules, say I want to do use the problem line, and am willing 
to assume that ptr2 always has the same value as ptr.  Could I have two 
identifiers "ptr" and "ptr2" in the front-end point to the same VAR_DECL 
record pointer?   Another route is change the declaration mechanism.  The 
problem here is that there is a great deal of guard code in 
c-typeck.c/digest_init involving TREE_CONSTANT checks.  Why are these checks 
needed?

Many thanks,
-Wei

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar – get it now! 
http://clk.atdmt.com/AVE/go/onm00200415ave/direct/01/



More information about the Gcc mailing list