#3653 closed defect (fixed)
Evaluation of lists (stringReal looses type?)
| Reported by: | Henning Kiel | Owned by: | Martin Sjölund |
|---|---|---|---|
| Priority: | critical | Milestone: | 1.9.4 |
| Component: | Code Generation | Version: | |
| Keywords: | Cc: | Martin Sjölund |
Description (last modified by )
I have the following simple code:
package Main public function main input list<String> args; output list<String> out; protected list<Real> r_arr; list<String> s_arr; algorithm r_arr := list(stringReal(s) for s in args); s_arr := list(String(r) for r in r_arr); out := listAppend(args,s_arr); end main; end Main;
I run it with omc +g=MetaModelica and the following script:
loadFile("Main.mo");
getErrorString();
Main.main({"1","2","3","4","5","6","7","8"});
getErrorString();
and get the following error:
true
""
"Error: Error building simulator. Build log: clang -I"/Users/henning/src/OpenModelica/build/include/omc/c" -g -O0 -march=native -c -o Main_main.o Main_main.c
/Users/henning/src/OpenModelica/mmc/Main.mo:11:16: warning: implicit declaration of function 'modelica_metatype_to_modelica_string' is invalid in C99 [-Wimplicit-function-declaration]
tmp4 = modelica_metatype_to_modelica_string(_r, ((modelica_integer) 0), 1);
^
/Users/henning/src/OpenModelica/mmc/Main.mo:11:14: warning: incompatible integer to pointer conversion assigning to 'modelica_string' (aka 'void *') from 'int' [-Wint-conversion]
tmp4 = modelica_metatype_to_modelica_string(_r, ((modelica_integer) 0), 1);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 warnings generated.
clang -I"/Users/henning/src/OpenModelica/build/include/omc/c" -g -O0 -march=native -c -o Main_main_records.o Main_main_records.c
clang -single_module -dynamiclib -flat_namespace -o Main_main.dylib Main_main.o Main_main_records.o -I"/Users/henning/src/OpenModelica/build/include/omc/c" -g -O0 -march=native -L"/Users/henning/src/OpenModelica/build/lib/x86_64-darwin15.3.0/omc" -Wl,-rpath,'/Users/henning/src/OpenModelica/build/lib/x86_64-darwin15.3.0/omc' -lOpenModelicaRuntimeC -llapack -lblas -lm -lm
Undefined symbols for architecture x86_64:
"_modelica_metatype_to_modelica_string", referenced from:
_omc_Main_main in Main_main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Main_main] Error 1
"
So, list(stringReal(...)...) seems to loose information of element type (should be modelica_real, but is modelica_metatype).
Change History (9)
comment:1 by , 10 years ago
| Description: | modified (diff) |
|---|---|
| Summary: | Evaluation of lists → Evaluation of lists (stringReal looses type?) |
comment:2 by , 10 years ago
comment:3 by , 10 years ago
| Cc: | added |
|---|
comment:4 by , 10 years ago
| Priority: | normal → critical |
|---|
Problem ist connected to decomposition of lists:
The following code fails to compile, whereas when you use the two other lines which create an intermediate Real variable, everything works fine.
function xs
output String s="";
protected
list<Real> Lr={1,2,3};
Real k;
algorithm
for r in Lr loop
// k:=r;
// s:=stringAppend(s,String(k));
s:=stringAppend(s,String(r));
end for;
end xs;
comment:5 by , 10 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:7 by , 10 years ago
| Milestone: | Future → 1.9.4 |
|---|---|
| Resolution: | → fixed |
| Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.

When I change
s_arr := list(String(r) for r in r_arr);to
s_arr := list(realString(r) for r in r_arr);omc seems to try to open file "1" (first argument from call to Main.main):