BetterC is so much bugs, is Walter really use it in DMD?
test
test at gmail.com
Thu Oct 25 12:47:17 UTC 2018
==================
import core.stdc.stdio;
version(D_BetterC) {
extern(C) void main() {
start;
}
} else {
void main(){
start;
}
}
struct Node {
@disable this();
@disable this(this);
int _count = 0;
this(int i){
_count =i ;
}
void add(){
_count++;
}
void dec(){
_count--;
}
}
struct Proxy {
Node* p ;
this(Node* n){
assert(n);
p = n ;
p.add;
}
~this() {
printf("~this(%x, p=%x)\n", &this, p) ;
drop ;
}
void opAssign(ref Proxy other){
printf("opAssign(ref this=%x, %x), other=%x, %x\n", &this, p,
&other, other.p) ;
drop ;
assert(other.p);
p = other.p ;
p.add ;
}
this(this) {
printf("this(this)\n") ;
if( p ) p.add ;
}
void opAssign(Proxy other){
printf("opAssign(this=%x, %x), other=%x, %x\n", &this, p,
&other, other.p) ;
drop;
if( other.p ) {
p = other.p ;
p.add ;
}
}
void drop(){
if( p ) {
p.dec;
}
p = null ;
}
}
__gshared Node n = Node(0) ;
__gshared ThreadS s ;
Proxy proxy;
void start(){
run(null);
}
void run(void* data) {
printf(" ========> run.enter\n") ;
proxy = runFiber(&n);
printf(" ========> run.exit\n") ;
}
ref auto runFiber(Node* p){
auto fiber = ThreadS.getThisS.getFiber(p);
return fiber ;
}
struct ThreadS {
static auto getThisS(){
return &s;
}
ref auto getFiber(Node* p) {
return fromPointer(p) ;
}
}
ref auto fromPointer(Node* p) {
return Proxy(p) ;
}
version(D_BetterC) extern(C) {
__gshared int _d_eh_personality(int, int, size_t, void*, void*)
{ return 0;};
__gshared void _d_eh_resume_unwind(void*) { return ;};
}
=================================
with -BetterC
========> run.enter
~this(c7da5060, p=3e40030)
opAssign(this=b40574b0, 0), other=c7da5030, 0
~this(c7da5030, p=0)
========> run.exit
without -BetterC
========> run.enter
opAssign(this=ffd1ab60, 0), other=885b32f0, 8f8da960
~this(885b32f0, p=8f8da960)
========> run.exit
Take me 16 hours to find this bug, Is your people really use it
to build compiler ?
Really is a good way to waste time to use this.
More information about the Digitalmars-d
mailing list