Bug Report: conditional break using bit field

From: Thanh Vuong (vuong_at_cadence.com)
Date: Fri Jan 04 2002 - 03:28:38 GMT


Hello,

Attached please find a small program that shows a bug in conditional
break in UPS.
I ran this program on Sun Solaris 2.7.

Regards,

Thanh


/* This small program shows a bug 
   in conditional break using bit field */

typedef struct s1 s1;
typedef struct s2 s2;

struct s1 {
    unsigned a;
    unsigned b;
};

struct s2 {
    unsigned a:10;
    unsigned b:10;
};

main()
{
    int i;
    s1 x[10];
    s2 y[10];

    for (i = 0; i < 10; i++) {
	x[i].a = i;
	x[i].b = i;
    }

    for (i = 0; i < 10; i++) {
	/* if (x[i].a == 5) #stop; --> would stop when i == 5 */
	printf("%d\n", x[i].a);
	/* if (x[i].b == 7) #stop; --> would stop when i == 7 */
	printf("%d\n", x[i].b);
    }

    for (i = 0; i < 10; i++) {
	y[i].a = i;
	y[i].b = i;
    }

    for (i = 0; i < 10; i++) {
	/* if (y[i].a == 5) #stop; --> would never stop */
	printf("%d\n", y[i].a);
	/* if (y[i].b == 7) #stop; --> would never stop */
	printf("%d\n", y[i].b);
    }
}


This archive was generated by hypermail 2.1.4 : Wed Feb 13 2002 - 21:51:34 GMT