Dynamic arrays allocation size
bearophile
bearophileHUGS at lycos.com
Tue Mar 26 11:20:30 PDT 2013
Steven Schveighoffer:
> If we treated it as an error, then it would be very costly to
> implement, every operation would have to check for overflow.
I have used similar tests and it's not very costly, not
significantly more costly than array bound tests.
In the meantime Clang has introduced similar run-time tests for
C/C++ code. So C/C++ are now better (more modern, safer) than the
D language/official compiler in this regard.
(And Issue 4835 is about compile-time constants. CFFE is already
plenty slow, mostly because of memory allocations. Detecting
overflow in constants is not going to significantly slow down
compilation, and it has no effect on the runtime. Even GCC 4.3.4
performs such compile-time tests.)
> The CPU does not assist in this.
The X86 CPUs have overflow and carry flags that help.
Bye,
bearophile
More information about the Digitalmars-d
mailing list