[Bug 196] Error building core/thread.d

via D.gnu d.gnu at puremagic.com
Wed Oct 7 05:41:36 PDT 2015


http://bugzilla.gdcproject.org/show_bug.cgi?id=196

--- Comment #12 from Johannes Pfau <johannespfau at gmail.com> ---
Smaller test case:
----------------------------------------
class ThreadError {}
void foo()
{
    __gshared error = new ThreadError();
}
----------------------------------------

Only happens for classes, not for structs. AFAICS this code creates two things:
* A variable in the data segment, properly named
  _D4test3fooFZ5errorC4test11ThreadError
  (A pointer, as classes are reference types)
* The result of ThreadError() interpreted in CTFE
  the data pointed to by D4test3fooFZ11ThreadErrorC4test11ThreadError, unnamed.


BTW: 
The unnamed variable is also in rodata instead of data, which is wrong:
----------------------------------------
class ThreadError
{
    int a;
}

void main()
{
    __gshared error = new ThreadError();
    error.a = 1;
}
----------------------------------------
segmentation fault (core dumped)  ./a.out
(works with dmd 2.068, haven't tested 2.066)

-- 
You are receiving this mail because:
You are watching all bug changes.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/d.gnu/attachments/20151007/72ea5ab6/attachment.html>


More information about the D.gnu mailing list