Opened 14 years ago
Last modified 13 years ago
#1525 closed defect
Calling Integer on enumeration type result in C compilation errors — at Version 4
| Reported by: | Per Östlund | Owned by: | Per Östlund |
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | Frontend | Version: | |
| Keywords: | Cc: | Per Östlund |
Description (last modified by )
The following model:
type E = enumeration(one, two, three);
function fun
input E e;
output Boolean b;
algorithm
if Integer(E) == 1 then
b := true;
else
b := false;
end if;
end fun;
model m
Boolean b = fun(E.two);
end m;
gives the error message:
fun.c:28:13: error: invalid operands to binary == (have 'integer_array' and 'long int')
while instantiating the model.
It's not clear to me if Integer(E) is actually valid Modelica or not, see Modelica issue m:#551. If it's not valid the Integer call in fun should simply be rejected, otherwise better type checking is required.
Change History (4)
comment:1 by , 14 years ago
comment:2 by , 14 years ago
But there exists an efficient implementation: E may not be a composite expression, so create a separate function called by reduction elaboration and in loops.
comment:3 by , 13 years ago
| Cc: | perost, perost → perost |
|---|---|
| Component: | → Backend |
| Description: | modified (diff) |
comment:4 by , 13 years ago
| Description: | modified (diff) |
|---|
Note:
See TracTickets
for help on using tickets.

E may only be used in ranges