ADTast-experimentalpthread-emulation
Last change
on this file since f403c46 was
d7ae173,
checked in by Thierry Delisle <tdelisle@…>, 3 years ago
|
Added test to detect regressions on bug #250
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | #include <fstream.hfa> |
---|
2 | |
---|
3 | forall(T & ) { |
---|
4 | struct nosize { |
---|
5 | T * field; |
---|
6 | void * canary; |
---|
7 | void * me; |
---|
8 | }; |
---|
9 | |
---|
10 | void ?{}(nosize(T) & this) { |
---|
11 | this.field = 0p; |
---|
12 | this.canary = 0x0D15EA5E0D15EA5Ep; |
---|
13 | this.me = &this; |
---|
14 | } |
---|
15 | |
---|
16 | void ^?{}(nosize(T) & this) { |
---|
17 | if(0x0D15EA5E0D15EA5Ep != this.canary) |
---|
18 | sout | "Dead canary in 'no size' dtor"; |
---|
19 | |
---|
20 | if(this.me != (void*)&this) |
---|
21 | sout | "Inconsistent address in dtor for 'no size'"; |
---|
22 | } |
---|
23 | |
---|
24 | void call_nosize(T * ) { |
---|
25 | nosize(T) obj; |
---|
26 | if(obj.me != (void*)&obj) |
---|
27 | sout | "Inconsistent address in ctor for 'no size'"; |
---|
28 | } |
---|
29 | } |
---|
30 | |
---|
31 | forall(T & | sized(T) ) { |
---|
32 | struct withsize { |
---|
33 | T * field; |
---|
34 | void * canary; |
---|
35 | void * me; |
---|
36 | }; |
---|
37 | |
---|
38 | void ?{}(withsize(T) & this) { |
---|
39 | this.field = 0p; |
---|
40 | this.canary = 0x0D15EA5E0D15EA5Ep; |
---|
41 | this.me = &this; |
---|
42 | } |
---|
43 | |
---|
44 | void ^?{}(withsize(T) & this) { |
---|
45 | if(0x0D15EA5E0D15EA5Ep != this.canary) |
---|
46 | sout | "Dead canary in 'with size' dtor" ; |
---|
47 | |
---|
48 | if(this.me != (void*)&this) |
---|
49 | sout | "Inconsistent address in dtor for 'with size' "; |
---|
50 | } |
---|
51 | |
---|
52 | void call_withsize(T * ) { |
---|
53 | withsize(T) obj; |
---|
54 | if(obj.me != (void*)&obj) |
---|
55 | sout | "Inconsistent address in ctor for 'with size' "; |
---|
56 | } |
---|
57 | } |
---|
58 | |
---|
59 | int main() { |
---|
60 | int i; |
---|
61 | call_nosize(&i); |
---|
62 | call_withsize(&i); |
---|
63 | sout | "All finished"; |
---|
64 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.