C Compiler Bug

Larry Jones scjones at sdrc.UUCP
Wed Sep 21 07:54:24 AEST 1988


Has anyone else run into a problem with bit-field assignments?  It seems
that the result of the assignment is not the value that was assigned to
the bit field as it should be, but rather the value of the int containing
the bit field as illustrated by the following program:

	#include <stdio.h>
	
	struct {
	   unsigned  :3;
	   unsigned a:1;
	   } x;
	
	main()
	   {
	
	   printf("Value of x.a = 1 is %d\n", x.a = 1);
	   }

	Value of x.a = 1 is 8

I've discovered this on System V/386 Version 2.2 - anyone know how pervasive
it is?  (Anyone have any good idea how to search mumblety thousand lines of
code for multiple assignments involving bit fields?)

----
Larry Jones                         UUCP: uunet!sdrc!scjones
SDRC                                      scjones at sdrc.uucp
2000 Eastman Dr.                    BIX:  ltl
Milford, OH  45150                  AT&T: (513) 576-2070
"Save the Quayles" - Mark Russell



More information about the Comp.unix.microport mailing list