Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C99 designated initializers broken with nested anonymous union #1365

Open
negge opened this issue Jan 4, 2025 · 1 comment
Open

C99 designated initializers broken with nested anonymous union #1365

negge opened this issue Jan 4, 2025 · 1 comment
Labels
bug C C compiler C99 Features specific to C99

Comments

@negge
Copy link

negge commented Jan 4, 2025

With C99 you can use designated initializers to set struct fields in any order. This code works fine with wcc386:

typedef struct Test Test;

struct Test {
  short a;
  unsigned b;
};

Test test[] = {
  { .a = 1, .b = 2 },
  { .b = 3, .a = 2 },
};

However, if you include an anonymous union this is no longer true:

typedef struct TestBad TestBad;

struct TestBad {
  short a;
  union {
    float c;
    unsigned b;
  };
};

TestBad test_bad[] = {
  { .a = 1, .b = 2 },
  { .b = 3, .a = 2 },
};

Compiling with Version 2.0 beta Jun 1 2024 01:58:48 (32-bit) I get the following error:

$ wcc386 -q test_bad.c 
test_bad.c(13): Error! E1118: ***FATAL*** Bad initializer quad
@jmalak
Copy link
Member

jmalak commented Jan 4, 2025

Thanks for your bug report.

@jmalak jmalak added the bug label Jan 4, 2025
@jmalak jmalak added C C compiler C99 Features specific to C99 labels Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug C C compiler C99 Features specific to C99
Projects
None yet
Development

No branches or pull requests

2 participants