tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] bug in structure initialization


From: Dave Dodge
Subject: [Tinycc-devel] bug in structure initialization
Date: Mon, 8 Nov 2004 19:54:49 -0500
User-agent: Mutt/1.4.2i

I don't know exactly where the bug is.  It seems to come from some
combination of casted and nested structure initializers, returning
structures by value, and the use of 64-bit types.  The following
program compiles, but segfaults at runtime when it attempts the third
style of initialization.  I'm using tcc 0.9.22:


/* the segfault goes away if this is changed to unsigned long */
typedef unsigned long long valtype;

typedef struct { valtype xval; } xtype;

xtype wrap_x(valtype const arg)
{
        return (xtype){ .xval = arg };
}

struct ystruct { xtype x; };

int main(void)
{
        /* this works */
        struct ystruct const y1 = {
                .x = { .xval = 0 }
        };

        /* this works */
        struct ystruct y2;
        y2.x = wrap_x(0);

        /* this segfaults */
        struct ystruct const y3 = {
                .x = wrap_x(0)
        };

        return 0;
}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]