[Vm-dev] clang and bytecodePrimMultiply

Holger Freyther holger at freyther.de
Tue Nov 24 19:51:44 UTC 2015


> On 24 Nov 2015, at 20:44, Eliot Miranda <eliot.miranda at gmail.com> wrote:
> 
> Hi All,

Hi!


> Given that arg and receiver can both have values > 64k, the result can of course overflow and there's no guarantee that because result = rcvr * arg, that (result / arg) == rcvr.
> 
> Am I missing something?  Are there flags I should be using?  This looks like a pretty basic issue.

I think you were already compiling with the -fwrapv option? Maybe it ignores it? I think the
blogpost from Nicolas Cellier[1] applies? I had a similar issue with GNU Smalltalk and clang
and I opted for using the GCC variant (that will be in newer clang releases too and we do not
have to think about the types) in the form of the __builtin_mul_overflow (the older variants are
either smul or smull and might be available in Apple's clang)[2]

i hope this helps
	holger



[1] http://smallissimo.blogspot.is/2015_04_01_archive.html
[2] http://clang.llvm.org/docs/LanguageExtensions.html


More information about the Vm-dev mailing list