davidgiven / ack

The Amsterdam Compiler Kit
http://tack.sf.net
Other
420 stars 59 forks source link

Why does this compile? #205

Closed drawkula closed 5 years ago

drawkula commented 5 years ago
$ cat bad.b
main() {
  auto i,m,x,y;

  m = 4;
  x = 0;
  y = 0;
  i = 0;
  while( i<m && x+y<=16384 ) {
    printf("%d*n",i);
    i++;
  }
}
$ /opt/ack/bin/ack -mlinux386 bad.b -o bad
$ ./bad 
$ # no output

B seems not to have && like C. That's ok. But why does ack throw no error here?

I stumbled over this while chiselling a Mandelbrot set example in B for Rosetta Code.

davidgiven commented 5 years ago

Ooh, nice --- been a while since I saw some code quite so misleading... it parses like this:

while ((I<m) & ((&x+y) <= 16384))

Sadly I think that's WAI.

drawkula commented 5 years ago

Thanks!