Stefan Behnel, 20.08.2012 20:55:
> Robert Bradshaw, 12.08.2012 09:00:
>> On Sat, Aug 11, 2012 at 1:19 PM, Stefan Behnel wrote:
>>> I ran into a couple of problems with the new C++ STL integration, just
>>> dumping them here for now.
>>>
>>> Invalid C code when using a stack allocated C++ vector inside of a
>>> generator, also lacking type conversion utility code:
>>>
>>> https://github.com/cython/cython/commit/d0a8e24720c3ed4e723b5a1b204bf375780f51bd
>>
>> The problem here is that utility code attached at this stage of the
>> pipeline gets ignored. In particular, we get to
>> https://github.com/cython/cython/blob/a7c689c10eea66f9fe384d7bc324a7aa50975f9d/Cython/Compiler/UtilityCode.py#L130
>> which I am at a loss to explain.
> 
> I debugged through this a bit and it seems to me that the main problem is
> that create_from_py_utility_code() is called too late. Currently, it's the
> code generation phase that calls it (Node.py, around line 2945). That's ok
> as long as it only generates C code, but it's way too late for Cython
> utility code at that point.
> 
> IIRC, the reason why we call it so late is that type conversions can change
> during several pipeline phases, even way after type analysis, and we want
> to make sure that we only serialise utility code that is really needed.
> Sadly, that applies to Cython utility code equally well.
> 
> Not sure what the right fix it here. I mean, we could call it earlier, even
> during type analysis, but that might let us generate code that is never
> needed, thus triggering a couple of C compiler warnings. Maybe that's
> acceptable at this point (better too much code than incomplete code).

It seems to work if I call it in DefNodeWrapper.analyse_declarations().
Given that we do not do any fancy stuff on argument types anyway, e.g. no
type inference, I don't think this can really hurt (but a test run is still
pending...).

Stefan

_______________________________________________
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel

Reply via email to