gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

new option -fauto-init in gm2-master


From: Gaius Mulley
Subject: new option -fauto-init in gm2-master
Date: Mon, 06 Jul 2020 11:56:20 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Hello,

I've added a new option on the master branch which automatically
initialises pointers to NIL (-fauto-init).  This works quite well with
-fsoft-check-all (or -fnil-check) as the plugin (and runtime) can detect
uninitialised pointers (in simple types).

Here is the output of the new regression tests in:
testsuite/gm2/switches/auto-init/fail

MODULE uninitptr2 ;

PROCEDURE foo ;
VAR
   p: POINTER TO CHAR ;
BEGIN
   p^ := 'a'
END foo ;

BEGIN
   foo
END uninitptr2.


$ gm2 -O -fsoft-check-all -fauto-init uninitptr2.mod
uninitptr2.mod:7:7: error: runtime error will occur, if this pointer value is 
ever dereferenced it will cause an exception (in procedure foo)

    7 |    p^ := 'a'
      |       ^~
MODULE uninitptr ;

VAR
   p: POINTER TO CHAR ;
BEGIN
   p^ := 'a'
END uninitptr.


$ gm2 -O -fsoft-check-all -fauto-init uninitptr.mod
uninitptr.mod:6:7: error: runtime error will occur, if this pointer value is 
ever dereferenced it will cause an exception (in program module uninitptr)

    6 |    p^ := 'a'
      |       ^~

the -fauto-init only works with variables of type pointer/address
(rather than record types or arrays).  It is straightforward to extend
this to initialise record types - but I'm less keen on auto initialising
arrays

hope this is useful,

regards,
Gaius



reply via email to

[Prev in Thread] Current Thread [Next in Thread]