2490 – extern(C++) can not handle structs as return types

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2490 - extern(C++) can not handle structs as return types
Summary: extern(C++) can not handle structs as return types
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Linux
: P2 normal
Assignee: Walter Bright
URL:
Keywords: wrong-code
Depends on:
Blocks:
Reported: 2008年12月03日 19:43 UTC by Jason House
Modified: 2015年06月09日 01:21 UTC (History)
0 users

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Jason House 2008年12月03日 19:43:28 UTC
The code below shows that the this pointer gets corrupted when this code compiles and runs. Sample output:
Bar = 0x81c33a8
This = 0xbf8dce20
cpp file:
#include <iostream>
struct foo{
 int i;
 int j;
};
class bar{
public:
 virtual foo getFoo(){
 std::cout << "This = " << this << std::endl;
 foo f;
 return f;
 }
};
bar* newBar(){
 bar* b = new bar();
 std::cout << "Bar = " << b << std::endl;
 return b;
}
d file:
extern(C++){
 struct foo{
 int i;
 int j;
 }
 interface bar{
 foo getFoo();
 }
 bar newBar();
}
void main(){
 bar b = newBar();
 foo f = b.getFoo();
}
Comment 1 Walter Bright 2008年12月25日 04:39:08 UTC
Fixed dmd 1.038 amd 2.022


AltStyle によって変換されたページ (->オリジナル) /