Silent Failure of Function called as Procedure in 13630

David Swindon in the Skype chat has discovered that 13630 and 13622 silently fail whan a function is called as a procedure.
In the following test code test 2 compiles with a warning but fails to run. All others run.

PROGRAM
                    MAP
                        Procedure_1(STRING p_input),STRING
                        Procedure_2(STRING p_input),STRING,PROC
                        
                    END
aVar                STRING(30)
    CODE
        
        CLEAR(aVar)

        MESSAGE('Test 1')
        aVar = Procedure_1('Test 1 P1 Return')
        
        MESSAGE('Test 2')
        Procedure_1('Test 2 P1 No Return')

        MESSAGE('Test 3')
        aVar = Procedure_2('Test 2 P2 Return')

        MESSAGE('Test 4')
        Procedure_2('Test 2 P2 No Return')
        
Procedure_1         PROCEDURE(STRING p_input) !,String
    CODE
        MESSAGE('P1 ' & p_input)
        RETURN p_input
        
Procedure_2         PROCEDURE(STRING p_input) !,String
    CODE
        MESSAGE('P2 ' & p_input)
        RETURN p_input
6 Likes

At least if you mark your procedure as PROC (as to avoid the compiler warning) it will work around this bug. Pretty scary nonetheless. :fearful:

1 Like

I created this test code that only Asserts on failure. You will need Debug On or Asserts=>on. It also checks that the return value works, and calling a procedure without a return value still happens.

Test13630IgnoreReturn  PROCEDURE()
IgnoreReturn_Incr1 PROCEDURE(*LONG p_InOutIcrement1),LONG
IgnoreReturn_Incr2 PROCEDURE(*LONG p_InOutIcrement2),LONG,PROC 
NoReturn_Incr3     PROCEDURE(*LONG p_InOutIcrement3)  

code

Test13630IgnoreReturn  PROCEDURE()
N   LONG 
R   LONG 
    CODE
  OMIT('!***debug on***',_DEBUG_)
      Message('Test13630IgnoreReturn  Test requires Debug Build') 
  !***debug on***
    N=1
    IgnoreReturn_Incr1(N)  !Check Return Ignored
    ASSERT(N=2,'IgnoreReturn_Incr1() not called? N=' & N)

    N=1
    IgnoreReturn_Incr2(N)  !Check Return Ignored
    ASSERT(N=3,'IgnoreReturn_Incr2() not called? N=' & N)

    N=1
    NoReturn_Incr3(N)  !Check No Return still called
    ASSERT(N=4,'NoReturn_Incr3() not called? N=' & N)

    N=1
    R=IgnoreReturn_Incr1(N)  !Check Return worked
    ASSERT(R=2,'IgnoreReturn_Incr1() return not 1, R=' & R)

    N=1
    R=IgnoreReturn_Incr2(N)  !Check Return worked
    ASSERT(R=3,'IgnoreReturn_Incr2() return not 3, R=' & R)

    message('Test13630IgnoreReturn() all done')
    
IgnoreReturn_Incr1 PROCEDURE(*LONG p_InOutIcrement1)!,LONG
    CODE 
    p_InOutIcrement1 += 1
    RETURN p_InOutIcrement1
IgnoreReturn_Incr2 PROCEDURE(*LONG p_InOutIcrement2)!,LONG,PROC 
    CODE  
    p_InOutIcrement2 += 2
    RETURN p_InOutIcrement2
NoReturn_Incr3 PROCEDURE(*LONG p_InOutIcrement3)
    CODE 
    p_InOutIcrement3 += 3
    RETURN

That is scary. I can’t update to 11.1.xxx because I rely on Andy’s ClarionTools and he has bene unable to make them work with v 11.1.xxx. Wat was the last 11.0.xxx version? Maybe I can get that download?

Mark

11630 is fine as long as you fix the code so you don’t get that warning. You can change all the calls with the warning by adding Junk#=BlargFunction() so it is a function call. Or change the Procedure prototype by adding PROC on all APPs that get the warning.

Hope this helps others. This issue was fixed in a 11.1 build.

http://softvelocity.cachefly.net/Clarion-11/Readme_11.1.13744.txt

— Clarion 11.1.13744 June 4, 2021 ----- Fixes/Changes/Features–/
…
FIX: Warning “Calling function as procedure” cancelled the call being made