@@ -1145,12 +1145,7 @@ class TypeInfo_Struct : TypeInfo
1145
1145
return false ;
1146
1146
else if (xopEquals)
1147
1147
{
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);
1154
1149
}
1155
1150
else if (p1 == p2)
1156
1151
return true ;
@@ -1171,14 +1166,7 @@ class TypeInfo_Struct : TypeInfo
1171
1166
if (! p2)
1172
1167
return true ;
1173
1168
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);
1182
1170
else
1183
1171
// BUG: relies on the GC not moving objects
1184
1172
return memcmp (p1, p2, initializer().length);
@@ -1225,10 +1213,21 @@ class TypeInfo_Struct : TypeInfo
1225
1213
1226
1214
@safe pure nothrow
1227
1215
{
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;
1232
1231
1233
1232
enum StructFlags : uint
1234
1233
{
0 commit comments