[Issue 10] New: ARM: runnable/opover2.d fails: xopEquals fallback aborts instead of throwing Exception
gdc-bugzilla at gdcproject.org
gdc-bugzilla at gdcproject.org
Tue Sep 25 03:22:44 PDT 2012
http://gdcproject.org/bugzilla/show_bug.cgi?id=10
Bug #: 10
Summary: ARM: runnable/opover2.d fails: xopEquals fallback
aborts instead of throwing Exception
Classification: Unclassified
Product: GDC
Version: development
Platform: ARM
OS/Version: Linux
Status: NEW
Severity: normal
Priority: Normal
Component: gdc
AssignedTo: ibuclaw at gdcproject.org
ReportedBy: johannespfau at gmail.com
Reduced example:
--------------
void main()
{
// xopEquals NG
struct S2a
{
bool opEquals(S2a rhs) //Add const here and everything OK
{return false; }
}
S2a s;
//Should throw exception, instead aborts
typeid(S2a).equals(&s, &s);
}
---------------
Compile:
gdc opover2.d -o opover2.exe
./opover2.exe
Aborted
Incomplete gdb backtrace:
---------------
Program received signal SIGABRT, Aborted.
0x40106bfc in raise () from /lib/arm-linux-gnueabihf/libc.so.6
(gdb) bt
#0 0x40106bfc in raise () from /lib/arm-linux-gnueabihf/libc.so.6
#1 0x4010a97c in abort () from /lib/arm-linux-gnueabihf/libc.so.6
#2 0x00008bd8 in ?? ()
#3 0x00008bd8 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
---------------
I started looking into this issue, this is what I found:
The TypeInfoStruct.equals function is set in TypeInfoStructDeclaration::toDt
(typinf.c):
---------------
if (sd->xeq)
dtxoff(pdt, sd->xeq->toSymbol(), 0, TYnptr);
else
dtsize_t(pdt, 0);
---------------
xeq is built in clone.c, StructDeclaration::buildXopEquals.
* If no opEquals function is defined, it return NULL. This is working.
* If an opEquals function was found, it tries to produce code to call this
function. If this succeeds, everything is working. If this fails, for example
because opEquals isn't const, it returns the object._xopEquals function. This
is what happens in this test case and isn't working.
object._xopEquals is defined in druntime:
bool _xopEquals(in void*, in void*)
{
throw new Error("TypeInfo.equals is not implemented");
}
calling it directly is working:
object._xopEquals(null, null); //Throws as expected.
I'm not sure if this is the root cause, but this is fishy: (TypeInfo_Struct)
override equals_t equals(in void* p1, in void* p2) @trusted pure nothrow const
but:
bool _xopEquals(in void*, in void*)
Could be another issue of the recent commit, fixing pure/nothrow attributes on
functions with asserts:
d-decls.cc(FuncDeclaration::toSymbol): Don't set any pure/nothrow attributes if
asserts are generated in code.
This can't detect the thrown Error in this case, as it's thown via a function
pointer.
--
Configure issuemail: http://gdcproject.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all issue changes.
More information about the D.gnu
mailing list