Opened 12 years ago

Closed 12 years ago

#1851 closed enhancement (fixed)

Warn on unassigned output variables (Using unbound output variables causes segfault)

Reported by: adabe588@… Owned by: Martin Sjölund
Priority: high Milestone: 1.9.0
Component: Frontend Version: trunk
Keywords: Cc:

Description

I'm not sure if I have filed a ticket about this before, I couldn't find it...

This code contains an output variable in the function part that is never assigned, when this value is used afterwards the program segfaults. No warning is given that the output variable isn't assigned a value, so debugging is fairly hard. It would be nice to get a warning if the compiler can tell that an output variable isn't assigned, or if it isn't sure.

Call Test.main() to reproduce.

package Test

function toList
  input Tuple<Integer,Integer> t;
  output List<Integer> list;
algorithm
  list := match t
    local Integer n;
    case (_,n) then toList_helper(n);
  end match;
end toList;

protected function toList_helper
  input Integer node;
  output List<Integer> list;
algorithm
  list := {};
end toList_helper;

function part
  output Tuple<Integer,Integer> a;
  output Tuple<Integer,Integer> b;
algorithm
  (a,a) := ((1,2),(1,2));
end part;



function main
protected
  List<Integer> resB;
  Tuple<Integer,Integer> b;
algorithm
  (_,b) := part();
  resB := toList(b);
end main;

end Test;

Change History (2)

comment:1 by Martin Sjölund, 12 years ago

Component: BackendFrontend
Owner: changed from somebody to Martin Sjölund
Status: newaccepted

comment:2 by Martin Sjölund, 12 years ago

Resolution: fixed
Status: acceptedclosed

Fixed in r13133.

Note: See TracTickets for help on using tickets.