On 2/3/21 5:15 PM, Joseph Myers wrote:
On Wed, 3 Feb 2021, Martin Sebor via Gcc-patches wrote:

+/* Return true of T1 and T2 are matching types for the purposes of
+   redeclaring a variable or a function without a prototype (i.e.,
+   considering just its return type).  */

I think this comment is confusing (it suggests it's checking something
looser than the notion of compatibility checked by comptypes, but it's
actually checking something stricter).  But I also think it's wrong to do
anything restricted to the return type.

For example, I think the following should be rejected, as enum E and
unsigned int end up incompatible and quite likely ABI-incompatible.

enum E;
void f(enum E);
void f(unsigned int);
enum E { x = 1ULL << 63 };

Maybe the ICE is specific to the case of return types, but I think the
same rules about type compatibility should apply regardless of precisely
where the incomplete enum type appears.

Ah, it's even more wide-spread than I realized.


I'd expect the natural fix for this PR to involve making
comptypes_internal treat an incomplete enum as incompatible with an
integer type.  Only if that causes too many problems should we then look
at other approaches.


Let me look into it then.

Martin

Reply via email to