Question about pragma mangle

Johannes Pfau nospam at example.com
Sat Dec 21 16:00:52 PST 2013


I just ran the test suite with an x86/ARM cross-compiler and it looks
like we have no cross-compiler specific problems!

There's one interesting failing test case: in runnable/mangle.d:

//UTF-8 chars
__gshared pragma(mangle, "test_эльфийские_письмена_9") ubyte test9_1;
__gshared extern pragma(mangle, "test_эльфийские_письмена_9") ubyte
test9_1_e;

void test9()
{
	import std.stdio;
    test9_1 = 42;
    writefln("test9_1 = %s", test9_1);
    writefln("test9_1_e = %s", test9_1_e);
    assert(test9_1_e == 42);
}

The assert fails with optimization enabled iff the writelns are
removed. I haven't verified this yet but I guess that gcc reorders the
read/write to the symbol(s) when optimization is enabled.

So: If we have symbols with the same mangled name, do we guarantee
that reordering won't happen? What would be the best way to rewrite
this test case so it doesn't rely on ordering or can't be reordered?

Placing the read/write into extra functions could work, but inlining
could cause problems...



More information about the D.gnu mailing list