[LLVMdev] Reference Manual Clarifications 2
Joachim Durchholz
jo at durchholz.org
Sun Apr 20 01:27:11 PDT 2008
Am Samstag, den 19.04.2008, 16:24 -0700 schrieb Jon Sargeant:
> First, I can assign -1 to
> the count to indicate an invalid or unknown value.
This is a C-ism. In a language that supports discriminated unions well,
you'd do something like
type AllocaCount = Invalid | Unknown | Known int
(where Invalid, Unknown and Known are the constants that do the
distinction between union variants).
> Second, if I attempt
> to allocate a negative count, I can print an assertion failure and abort
> the program. Had I interpreted the count as an unsigned value, the
> program would attempt to allocate anywhere from 2 gigabytes to 4
> gigabytes.
Which might be exactly what it's supposed to do. Suppose you're writing
heap management code.
> I'm not necessarily saying that NumElements should be
> signed, only that the choice between signed and unsigned is not obvious.
Obviously, obviousness is in the eye of the beholder :-)
(SCNR)
Regards,
Jo
More information about the llvm-dev
mailing list