Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 (Tek) 9/26/83; site hercules.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxj!houxm!vax135!cornell!uw-beaver!tektronix!teklds!hercules!archiel From: archiel@hercules.UUCP (Archie Lachner) Newsgroups: net.lang.c Subject: cc optimizer bug Message-ID: <292@hercules.UUCP> Date: Tue, 2-Oct-84 12:02:50 EDT Article-I.D.: hercules.292 Posted: Tue Oct 2 12:02:50 1984 Date-Received: Fri, 5-Oct-84 05:45:57 EDT Organization: Tektronix, Beaverton OR Lines: 70 Several people have asked for copies of the program that exercises the cc optimizer bug that I reported recently. One suggested that I submit it to this news group. Though a fix for the bug has already been posted, I'm happy to comply. ------- #includemain() { union { int one_word; /* one-word form */ struct { unsigned int type:7; /* type */ unsigned int flag_1:1; /* flag no 1 */ unsigned int flag_2:1; /* flag no 2 */ unsigned int count:7; /* count of whatever */ unsigned int number:16; /* number of "things" */ } split; /* split form */ } field_union; int type; int flag_1; int flag_2; int count; int number; field_union.one_word = 0x300; fprintf(stdout, "foobar: field_union = %d (%x hex)\n", field_union.one_word, field_union.one_word); type = field_union.split.type; fprintf(stdout, "foobar: type = %d\n", type); flag_1 = field_union.split.flag_1; fprintf(stdout, "foobar: flag_1 = %d\n", flag_1); flag_2 = field_union.split.flag_2; fprintf(stdout, "foobar: flag_2 = %d\n", flag_2); count = field_union.split.count; fprintf(stdout, "foobar: count = %d\n", count); /* * when this is compiled with optimization, "number" will be 3 * * it should be 0 * * the error can be traced to line 54 of the assembler output * produced using "cc -O -S" * * the source address in a "movzwl" instruction is incorrect */ number = field_union.split.number; fprintf(stdout, "foobar: number = %d\n", number); exit(0); } -- Archie Lachner Logic Design Systems Division Tektronix, Inc. uucp: {ucbvax,decvax,pur-ee,cbosg,ihnss}!tektronix!teklds!archiel CSnet: archiel@tek ARPAnet: archiel.tek@csnet-relay