University of Virginia, Department of Computer Science
CS655: Programming Languages
Spring 2000

Mock Trial: Court's Exhibit 2

The following program is introduced into evidence:
# include <stdio.h>

typedef struct { char a; } buffer;

int main (void) {
  struct buffer { int a; } ;
  int x = 4 //**/ 2
    ;
  buffer b;
  b.a = 655;

  fprintf (stderr, "b.a = %d / x = %d\n", b.a, x);
}
Here is a transcript of what happens when it is compiled with a conforming C compiler:
> gcc --ansi struct.c
struct.c: In function `main':
struct.c:10: warning: overflow in implicit constant conversion
            This is just a warning not a violation of language specification.
            Most compilers would not complain.
> a.out
b.a = -113 / x = 2
Here is a transcript of what happens when it is compiler with a conforming C++ compiler:
> g++ --ansi struct.c
> a.out
b.a = 655 / x = 4

Any participant in the trial may use this as they see fit.


CS 655 University of Virginia
CS 655: Programming Languages
cs655-staff@cs.virginia.edu
Last modified: Mon Feb 26 12:48:20 2001