[M3devel] A bug in M3C

Rodney M. Bates rodney_bates at lcwb.coop
Wed Feb 5 00:43:58 CET 2014


Jay,

The attached M3 program compiles using cm3cg on AMD64_LINUX.
Using M3C, it generates C code that the C compiler chokes on:

rodney at allegheny:~/proj/m3/exp/m3cbug1/src$ cm3 -keep
--- building in ../AMD64_LINUX ---

new source -> compiling Test.m3
../src/Test.m3: In function ‘Test__P’:
../src/Test.m3:12: error: aggregate value used where an integer was expected
   compile_c => 1
C compiler failed compiling: Test.m3.c
compilation failed => not building program "test"
Fatal Error: package build failed

A much larger program from which this case is reduced suffers the same problem
compiling the equivalent code using M3C, but compiles and executes as expected
using cm3cg.

Removing or simplifying the IF statement makes it go away.
-------------- next part --------------
M3_BACKEND_MODE = "C"
%M3_FRONT_FLAGS = ["-unfold_nested_procs"]
import("libm3")
implementation("Test")
program ("test")
-------------- next part --------------
MODULE Test EXPORTS Main 

; TYPE T = ARRAY [ 0 .. BYTESIZE ( WIDECHAR ) - 1 ] OF CHAR 
; CONST C = T { '\x05' , .. } 

; PROCEDURE P 
    ( READONLY Arr : T ; Msg : TEXT ) 

  = VAR LMsg : TEXT 

  ; BEGIN 
      IF Arr # C 
      THEN 
        LMsg := Msg & "XYZ" 
      END (* IF *) 
    END P 

; BEGIN 
    P ( C , "ABC" ) 
  END Test
. 


More information about the M3devel mailing list