@@ -1145,12 +1145,7 @@ class TypeInfo_Struct : TypeInfo
11451145 return false ;
11461146 else if (xopEquals)
11471147 {
1148- version (GNU )
1149- { // BUG: GDC and DMD use different calling conventions
1150- return (* xopEquals)(p2, p1);
1151- }
1152- else
1153- return (* xopEquals)(p1, p2);
1148+ return (* xopEquals)(p1, p2);
11541149 }
11551150 else if (p1 == p2)
11561151 return true ;
@@ -1171,14 +1166,7 @@ class TypeInfo_Struct : TypeInfo
11711166 if (! p2)
11721167 return true ;
11731168 else if (xopCmp)
1174- {
1175- version (GNU )
1176- { // BUG: GDC and DMD use different calling conventions
1177- return (* xopCmp)(p1, p2);
1178- }
1179- else
1180- return (* xopCmp)(p2, p1);
1181- }
1169+ return (* xopCmp)(p1, p2);
11821170 else
11831171 // BUG: relies on the GC not moving objects
11841172 return memcmp (p1, p2, initializer().length);
@@ -1225,10 +1213,21 @@ class TypeInfo_Struct : TypeInfo
12251213
12261214 @safe pure nothrow
12271215 {
1228- size_t function (in void * ) xtoHash;
1229- bool function (in void * , in void * ) xopEquals;
1230- int function (in void * , in void * ) xopCmp;
1231- string function (in void * ) xtoString;
1216+ size_t function (in void * ) xtoHash;
1217+ /* The xopEquals and xopCmp function pointers usually point to the struct's
1218+ * opEquals and opCmp methods. If the method doesn't take its single
1219+ * argument by reference, the front-end injects a static __xopEquals/
1220+ * __xopCmp function (taking 2 arguments, lhs `p` and rhs `q`).
1221+ *
1222+ * In the method case, lhs `p` is the `this` argument and must be passed
1223+ * as first argument before rhs `q`.
1224+ * Enforce this arguments order by marking the pointed-to functions as
1225+ * using the C calling convention, for which the arguments are never
1226+ * reversed (contrary to `extern (D)`).
1227+ */
1228+ extern (C ) bool function (in void * , in void * ) xopEquals;
1229+ extern (C ) int function (in void * , in void * ) xopCmp;
1230+ string function (in void * ) xtoString;
12321231
12331232 enum StructFlags : uint
12341233 {
0 commit comments