lkml.org 
[lkml]   [1998]   [May]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: Egcs 1.0.3 & Linux
Date
Interesting point ...

"A month of sundays ago Khimenko Victor wrote:"
>
> #include <stdio.h>
> int a=0;
> int f(void) { a=1;return 1; }
> void main(void) { printf("%d",f()+a); }

Of course this is really

print (a=1)+a

in disguise, and depends on the order of evaluation of expressions with
side effects.

> Of course this code contains nasty bug and two compilers could generate two
> programs with different behaviour -- one will write 1 and other will write 2.

Indeed. Indeed the code is not in error.

> if code is compiled bu compiler without bugs and works just fine still does
> not mean that code does not contains bugs! And looks like it's possible to
> prove that you could not write program able to catch all such bugs (this is

You are asking if a compiler can detect when the defined semantics of the
programming language does not assign a uniquely determined semantics to
a given program? Durrrrrrrrrrrrr ... well if it could, then I could
take any program A(x) and write the program A'[k];B, where B is your
example program above and A'[k] is the version of A with all its printfs
removed and an "x=k;" inserted at the beginning, so that it can't do
anything except terminate or not.
A'[k];B is a nondeterministic program precisely when A(k) halts (because
B can be any of two things) and deterministic when A(k) does not halt
(it does nothing). A compiler which correctly detected these two
situations would be solving the halting problem for A(k), which is
impossible for a machine.

So no. No compiler can detect the ambiguities CORRECTLY. It can however
warn you that you may have dangerous constructs around, and err on the
side of caution. Or it may consistently ignore dangers like that. It
must do one or the other.


> not trivial task, unfortunatelly) ! Really this is exactly situation with egcs

Trivial.

> and kernel -- there are few known (and god knows how many unknown :-) places
> where egcs will generate wrong code since source code contans bugs like
> bug above... Most of them is cleaned out in 2.1.102 but noone knows -- how
> many still left there :-(( By the way I am using pgcc 1.0.2 for all compilations
> (including kernel, of course). I am not using 2.0.x kernels through ...
>

Nice.


Peter ptb@it.uc3m.es

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu

\
 
 \ /
  Last update: 2005-03-22 13:42    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site