https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120497
Bug ID: 120497 Summary: An error is generated when returning a var variable which is a pointer Product: gcc Version: 16.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: modula2 Assignee: gaius at gcc dot gnu.org Reporter: gaius at gcc dot gnu.org Target Milestone: --- The following code causes fails to compile: $ gm2 -c ReturnType2.mod ReturnType2.mod:9:11: error: the return type 'bar' used in procedure 'foo' 9 | PROCEDURE foo (VAR value: bar) : bar ; | ^~~ ReturnType2.mod:11:4: error: is incompatible with the returned expression 'foo' 11 | RETURN value | ^~~~~~~~~~~~ $ cat ReturnType2.mod MODULE ReturnType2 ; TYPE bar = POINTER TO RECORD field: CARDINAL ; END ; PROCEDURE foo (VAR value: bar) : bar ; BEGIN RETURN value END foo ; VAR b: bar ; BEGIN b := NIL ; b := foo (b) END ReturnType2.