4 days ago

On Friday, 18 October 2024 at 14:41:15 UTC, Mark Bauermeister wrote:

>

On Thursday, 17 October 2024 at 02:47:03 UTC, Mai Lapyst wrote:

>

[...]

Yea. I forgot about the sizeof division being wrong. I replaced all calls to ARRAY_LEN with <array>.length.

[...]

Is the switch correct? I would expect to see case statements like case goto_OP_IGNORE: etc. etc.

Jordan

4 days ago
On Friday, 18 October 2024 at 14:41:15 UTC, Mark Bauermeister wrote:
> ...No more segfaults thus far but strangely the proper switch case...

One thing that I can think looking at your code:

import std.stdio;

void main(){
    int op = 1;
    switch(op){
        default: writeln("default"); return;
        version(XYZ){
			case 1: writeln(op); break;
        }
        case 2: writeln(op);
    }
}

Since XYZ is never set, case 1 will never hit and it will print "default". if you comment or take "version(XYZ)" out there it will work.

Code: https://run.dlang.io/?compiler=dmd&args=-unittest&source=void+main%28%29%0A%7B%0A++++import+std.stdio+%3A+writefln%3B%0A++++import+std.algorithm.sorting+%3A+sort%3B%0A++++import+std.range+%3A+chain%3B%0A%0A++++int%5B%5D+arr1+%3D+%5B4%2C+9%2C+7%5D%3B%0A++++int%5B%5D+arr2+%3D+%5B5%2C+2%2C+1%2C+10%5D%3B%0A++++int%5B%5D+arr3+%3D+%5B6%2C+8%2C+3%5D%3B%0A++++%2F%2F+%40nogc+functions+are+guaranteed+by+the+compiler%0A++++%2F%2F+to+be+without+any+GC+allocation%0A++++%28%29+%40nogc+%7B%0A++++++++sort%28chain%28arr1%2C+arr2%2C+arr3%29%29%3B%0A++++%7D%28%29%3B%0A++++writefln%28%22%25s%5Cn%25s%5Cn%25s%5Cn%22%2C+arr1%2C+arr2%2C+arr3%29%3B%0A%7D%0A%0A

Matheus.
1 2
Next ›   Last »