[Issue 7932] New: protected method
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Apr 17 06:30:33 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7932
Summary: protected method
Product: D
Version: D1 & D2
Platform: x86_64
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: leandro.lucarella at sociomantic.com
--- Comment #0 from Leandro Lucarella <leandro.lucarella at sociomantic.com> 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)
out
{
printf("out: this=%p &n=%p n=%zu\n",
cast(void*) this, &n, n);
assert (N == n);
}
body
{
int dummy;
//printf("\n");
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;
x.f(1);
}
---
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: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list