[Top][All Lists]

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

[Tinycc-devel] Wrong code generation with anon structs

From: Pitr Kaye
Subject: [Tinycc-devel] Wrong code generation with anon structs
Date: Tue, 9 Apr 2019 12:33:53 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0


doing some experiments  about compiler support for anon structs, i found an erroneous assignment in tcc.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct a {
    int x;

struct b {
    int y;
    struct a;
} p1,p2;

int main() {
  p1.x = 8;
  printf("p1.y=%d  p1.x=%d\n",p1.y,p1.x);
  p2 = p1;
  printf("p2.y=%d  p2.x=%d\n",p2.y,p2.x);
  p1  = (struct b) { .y=5, .x=3 }; // this works
  printf("p1.y=%d  p1.x=%d\n",p1.y,p1.x);
  p2  = (struct b) { 5, 3 };       // this doesn't
  printf("p2.y=%d  p2.x=%d\n",p2.y,p2.x);

Output :

p1.y=0  p1.x=8
p2.y=0  p2.x=8
p1.y=5  p1.x=3
p2.y=0  p2.x=0  <-- wrong output


reply via email to

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