Issue Details (XML | Word | Printable)

Key: PCC-288
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Anders Magnusson
Reporter: Chris Spiegel
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
pcc

Compiler error with struct and arrays

Created: 31/Mar/11 04:58 AM   Updated: 30/Jul/12 03:20 PM
Component/s: pcc backend
Affects Version/s: None
Fix Version/s: None

Environment: pcc 1.0.0.BETA-20110330 on Linux 2.6.38.


 Description  « Hide
Code:
struct arg
{
  int type;
  char *name;
};

static struct arg NONE(void)
{
  return (struct arg){ .type = 0 };
}

int main(void)
{
  struct arg args[2] = { NONE(), NONE() };

  return 0;
}

With this, the following output is obtained:
t.c, line 14: warning: illegal combination of pointer and integer
t.c, line 14: compiler error: Cannot generate code, node 0x8557ebc op PCONV

Neither message is raised if either member of the struct is removed, or if the array is only one element long. As the array is lengthened (and calls to NONE() are appropriately added as initializers), the "illegal combination" error is repeated. It appears once for 2-3 elements, twice for 4-5, thrice for 6-7, and so on.

It doesn't matter what NONE() returns--it can be an empty function.

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Mans Rullgard added a comment - 03/Apr/11 04:49 PM
This failure looks possibly related:

struct foo {
    int a, b;
};

void foo(struct foo *f)
{
    struct foo x[2] = { f[0], f[1] };
}

$ pcc -c struct.c
struct.c, line 7: operands of = have incompatible types

With an array size of 1 it does not error, nor if the struct is changed to have only one member.

Anders Magnusson added a comment - 04/Sep/11 09:48 AM
The init code seems to fail to skip the whole struct after initializing the first element.
Bug probably somewhere around scalinit().

Anders Magnusson added a comment - 30/Jul/12 03:20 PM
And (at last!) fixed. Simple fix, but took a while to find.