[M3devel] zero sized structs?

mika at async.caltech.edu mika at async.caltech.edu
Thu Oct 4 20:23:39 CEST 2012


It seems that CM3 puts them at the "same address"....

UNSAFE MODULE Main;
IMPORT IO, Fmt;

TYPE
   T =  ARRAY [1..-1] OF INTEGER;

VAR t := NEW(REF T); u := NEW(REF T);
    v : T;
    w : T;
BEGIN
  IO.Put(Fmt.Int(LOOPHOLE(t,INTEGER), base := 16) & "\n");
  IO.Put(Fmt.Int(LOOPHOLE(u,INTEGER), base := 16) & "\n");
  IO.Put(Fmt.Int(LOOPHOLE(ADR(v),INTEGER), base := 16) & "\n");
  IO.Put(Fmt.Int(LOOPHOLE(ADR(w),INTEGER), base := 16) & "\n");
END Main.

(114)async:~/ttt/src>../AMD64_LINUX/prog
2269030
2269040
602218
602218

I don't see a problem with it.  Whoever thinks he needs to check whether
ADR(v) equals ADR(w) should be using a different programming language...

     Mika




More information about the M3devel mailing list