ooc

ArrayList iterator causes gcc to throw errors

Bug #393931 reported by Justin Poliey
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ooc
Fix Committed
Low
Unassigned

Bug Description

I was using ArrayList in some code I was writing, but no matter what I did ooc would compile the code fine, but gcc was throwing errors. Finally I decided to run the foreach-arraylist test, and it also errors. Here's an example session:

$ ooc -v tests/sugar/foreach/foreach-arraylist.ooc
Compiling source 'tests.sugar.foreach.foreach-arraylist'
Found dependency structs.List' imported from 'tests.sugar.foreach.foreach-arraylist, importing...
Compiling source 'structs.List'
Found dependency Iterable' imported from 'structs.List, importing...
Compiling source 'structs.Iterable'
Found dependency Iterator' imported from 'structs.Iterable, importing...
Compiling source 'structs.Iterator'
Compiling source 'OocLib'
Found dependency Iterator' imported from 'structs.List, importing...
Found dependency structs.ArrayList' imported from 'tests.sugar.foreach.foreach-arraylist, importing...
Compiling source 'structs.ArrayList'
Found dependency List' imported from 'structs.ArrayList, importing...
Found dependency Iterator' imported from 'structs.ArrayList, importing...
Found dependency Iterable' imported from 'structs.ArrayList, importing...
/usr/bin/gcc -std=c99 -c ooc_tmp/structs/ArrayList.c -I /opt/ooc/libs/headers -o ooc_tmp/structs/ArrayList.o
ooc_tmp/structs/ArrayList.c: In function '__structs_ArrayList_iterator':
ooc_tmp/structs/ArrayList.c:283: warning: return from incompatible pointer type
/usr/bin/gcc -std=c99 -c ooc_tmp/structs/List.c -I /opt/ooc/libs/headers -o ooc_tmp/structs/List.o
/usr/bin/gcc -std=c99 -c ooc_tmp/OocLib.c -I /opt/ooc/libs/headers -o ooc_tmp/OocLib.o
/usr/bin/gcc -std=c99 -c ooc_tmp/structs/Iterator.c -I /opt/ooc/libs/headers -o ooc_tmp/structs/Iterator.o
/usr/bin/gcc -std=c99 -c ooc_tmp/structs/Iterable.c -I /opt/ooc/libs/headers -o ooc_tmp/structs/Iterable.o
/usr/bin/gcc -std=c99 ooc_tmp/tests/sugar/foreach/foreach-arraylist.c ooc_tmp/structs/List.o ooc_tmp/structs/Iterable.o ooc_tmp/structs/Iterator.o ooc_tmp/OocLib.o ooc_tmp/structs/ArrayList.o -I /opt/ooc/libs/headers -L /opt/ooc/libs/ -l pthread -o ooc_tmp/foreach-arraylist /opt/ooc/libs/linux32/libgc.a
ooc_tmp/tests/sugar/foreach/foreach-arraylist.c: In function 'main':
ooc_tmp/tests/sugar/foreach/foreach-arraylist.c:10: warning: initialization from incompatible pointer type

Revision history for this message
Amos Wenger (amoswenger) wrote :

Those are only warnings, thus they don't prevent compilation / running the program.

They are caused by a lack of casts in the generated C code. If everything was casted correctly in the C code, there would be no warnings and it still would work perfectly.

This is an issue I considered low priority for the 0.2 release, since it doesn't prevent compilation etc., but I see it confuses people a lot.

You can have a better notification of whether the build was successful or not by running with the option:
$ ooc -backend=gcc,-s blah.ooc
where s means shout. Or, if you are running a 0.3 build (e.g. from git), you can simply do
$ ooc -shout blah.ooc
This will print a big fat [ OK ] or [FAIL].

Changed in ooc-language:
importance: Undecided → Low
status: New → Confirmed
Amos Wenger (amoswenger)
Changed in ooc-language:
status: Confirmed → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.