Summary: .bss section not used
           Product: D
           Version: D2
          Platform: All
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from Marco Leise <> 2012-01-19 05:10:25 PST ---
Consider this struct definition:

    struct Test1 {
        byte arr[1024 * 1024 * 10];

DMD for Windows places 10 MB into the BSS section, whereas DMD on Linux fails
to use the equivalent .bss section.

This is not always the case, as this declaration shows:

    struct Test2 {
        __gshared byte arr[1024 * 1024 * 10];

Now the struct is correctly placed inside .bss. But this can easily lead to bad
runtime behavior, as the last test case shows:

    struct Test {
        byte arr1[1024 * 1024 * 10];
        __gshared byte arr2[1024 * 1024 * 10];

    int main() {
        Test test;
        return 0;

This will SEGFAULT when the stack variable test is about to be initialized.

Other observations:
- Placing the array outside the struct, directly at module level results in a
small executable size. (It probably uses .tbss here correctly for thread local
- This and the above tests can be reproduced with GDC as well, so I assume the
bug is at the front-end stage.
- How is MacOSX affected ?
- What is the scope of __gshared, what can be attributed with it?

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to