[Vm-dev] dangerous translation of MiscPrimitivePlugin code
Nicolas Cellier
nicolas.cellier.aka.nice at gmail.com
Fri Jul 8 20:49:58 UTC 2016
Hi,
I don't know if it was reported yet, but we've got some nasty UB detected
by C Compiler warning in primitiveFindSubstring:
../../src/plugins/MiscPrimitivePlugin/MiscPrimitivePlugin.c:745:53:
warning: unsequenced modification and access to 'index' [-Wunsequenced]
while ((body[startIndex + index]) == (key[(index +=
1)])) {
Effectively, the sequence is well defined in Smalltalk, not in C.
See String>>#findSubstring:in:startingAt:matchTable:
(body at: startIndex + index) == (key at: (index := index + 1))
Since the CCodeGenerator does not handle this,
we should better decompose the Smalltalk code into several instructions.
Hint: mind the C compiler warnings, some of them are true positive!
Half my changes/fixes are driven by them.
Nicolas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20160708/19ff3534/attachment.htm
More information about the Vm-dev
mailing list