Parsing Bug?

56 views
Skip to first unread message

Brian Green

unread,
Jun 28, 2019, 7:20:53 PM6/28/19
to Intel SPMD Program Compiler Users
Using -> to dereference a struct is incorrectly complaining that it is being applied to a declared but not defined struct, when the struct in question is first forward declared:

test.ispc:21:5: Error: Member operator
        "->" can't be applied to
        declared but not defined struct
        type "uniform struct A".
    b.mA->mX = 3;
    ^^^^^^^^

This is using ispc-1.9.2.  Is this a known issue?  Am I incorrectly thinking that this should work?  The example below may look a little contrived, in practice we are hitting this issue when the forward declaration takes place in header files and the definition is only brought into the needed compilation units.

Cheers,
-Brian

----- test.ispc

// forward declaration of A
struct A;

struct B
{
    uniform A * uniform mA;
};

// definition of A
struct A
{
    int mX;
};


export void
run()
{
    B b;
    // BUG:  this does not compile ???
    b.mA->mX = 3;

    // but this is fine
    // uniform A * uniform a2 = b.mA;
    // a2->mX = 3;
}

Rajendrakumaran, Deepak

unread,
Jun 28, 2019, 8:33:12 PM6/28/19
to ispc-...@googlegroups.com

Hi,

 

Looks like a bug. If I add the struct A definition above  the struct B definition, then it compiles. But, that is not in line with what I’d expect considering c/c++ behavior(Just need the definition somewhere as long as it’s forward declared).

 

The below code compiles for what it’s worth. Thanks for reporting this and can you please create an issue on github?

 

----- test.ispc

 

// forward declaration of A
struct A;

 

// definition of A
struct A
{
    int mX;
};




struct B
{
    uniform A * uniform mA;
};

export void
run()
{

    B b;

    // BUG:  this does not compile ???
    b.mA->mX = 3;

 

    // but this is fine

    // uniform A * uniform a2 = b.mA;
    // a2->mX = 3;
}

 

Thanks,

Deepak

--
You received this message because you are subscribed to the Google Groups "Intel SPMD Program Compiler Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ispc-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ispc-users/6a1365c5-9aa1-4759-9364-0b7544eef5ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Brian Green

unread,
Jul 1, 2019, 5:14:21 PM7/1/19
to Intel SPMD Program Compiler Users

Looks like this issue has already been reported in the past:


-Brian

To unsubscribe from this group and stop receiving emails from it, send an email to ispc-...@googlegroups.com.

Rajendrakumaran, Deepak

unread,
Jul 1, 2019, 7:45:58 PM7/1/19
to ispc-...@googlegroups.com

Yeah. That looks like the same issue. I’ll update #284 once I look into it.

 

Thanks for pointing it out.

 

-Deepak

To unsubscribe from this group and stop receiving emails from it, send an email to ispc-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ispc-users/f52e6060-42e5-4ebb-a9dc-710d066cc2e5%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages