November 23, 2014 [Issue 13769] New: Wrong argument passing for variadic functions in 64 bits | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13769 Issue ID: 13769 Summary: Wrong argument passing for variadic functions in 64 bits Product: D Version: D2 Hardware: x86_64 OS: All Status: NEW Severity: enhancement Priority: P1 Component: DMD Assignee: nobody@puremagic.com Reporter: pro.mathias.lang@gmail.com The following code: ```` private unittest { import core.vararg, std.stdio; void fix() {} void test_bug(size_t bug, ...) { assert(bug == size_t.max); } void test_fixed(size_t bug, ...) { fix(); assert(bug == size_t.max); } void print_bug(size_t bug, ...) { writeln(bug); assert(bug == size_t.max); } void print_fix(size_t bug, ...) { fix(); writeln(bug); assert(bug == size_t.max); } print_bug(size_t.max); print_fix(size_t.max); test_fixed(size_t.max); test_bug(size_t.max); } ```` Will trigger an unittest when put any Phobos module (for simplicity, I tested std.algorithm). Example: ```` make[1]: Leaving directory '/mnt/shared/projects/dlang/druntime' 140734760252720 18446744073709551615 ****** FAIL std.algorithm core.exception.AssertError@std/algorithm.d(417): Assertion failure ---------------- generated/linux/release/64/unittest/libphobos2-ut.so(+0x28fb8e1) [0x7f2bf2fcd8e1] ```` As you see, the parameters passed during the first function call inside that function are wrong. I only appears with 64 bits parameters (including string). I couldn't find any stand-alone snippet that reproduce the error. My guess is that it might originate from the way it's tested (shared library), but I currently lack the time to investigate further. The issue was originally found in https://github.com/D-Programming-Language/phobos/pull/2677 This also outline the fact that variadic functions are poorly tested in Phobos. -- |
Copyright © 1999-2021 by the D Language Foundation