Outside array bounds
Alex
sascha.orlov at gmail.com
Sat Jul 7 08:35:27 UTC 2018
On Saturday, 7 July 2018 at 08:24:21 UTC, Timoses wrote:
> Interesting.. Looks like the compiler does some boundschecking
> during compile time. You could circumvent this:
>
>
> void process(T ...)(string ID, T args) {
> if (ID == "I1") { writeln(args.length, "\t", args[0]); }
> static if (T.length > 1) // only add below code if
> cond. true
> if (ID == "I2") { writeln(args.length, "\t",
> args[1]);}
> }
>
> Oddly, when leaving out the "static if" statement, the error
> still occurs when compiling with "-release" or with
> "-boundscheck=off"... I thought those would/should disable
> bounds checking at compile time???
Nonono ))
In this case, the bound checks are like interface checking... or
like type checking... As there are different processes
instantiations for different number of args.
I hope this can't be turned off so easily... ))))
More information about the Digitalmars-d-learn
mailing list