Summary: protected method
           Product: D
           Version: D1 & D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from Leandro Lucarella <> 
2012-04-17 06:31:25 PDT ---
This is a weird one:

extern (C) int printf(char* fmt, ...);

size_t N;

class C
    protected void f(size_t n)
        printf("out: this=%p &n=%p n=%zu\n",
                cast(void*) this, &n, n);
        assert (N == n);
        int dummy;
        N = n;
        printf("body: this=%p &dummy=%p &N=%p N=%zu\n",
                cast(void*) this, &dummy, &N, N);

void main()
    auto x = new C;

Compiling with dmd -m64 -O, the assertion fails, and the output is:
body: this=0x7f457090dcf0 &dummy=0x7fffc16ece98 &N=0x6fe2d0 N=1
out: this=0x7f457090dcf0 &n=0x7fffc16ecea8 n=4401614

All other flags seems to be irrelevant except for -release, of course, as the
out contract is not generated.

Uncommenting the commented out printf() fixes the problem. Removing the
protected attribute, or changing it to either public, private or package fixes
the problem too.

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

Reply via email to