mstorsjo wrote:
Just for reference, I noticed a small discrepancy to which cases GCC warns
about:
```c
struct A {
float a;
};
struct B {
long long a, b, c, d;
};
void ptrFunc(struct A *ptr) { }
void ptrFuncAlias(struct B *ptr) __attribute__((alias("ptrFunc")));
```
Here, the functions differ in the struct that the pointer parameter points to.
GCC doesn't warn about this at all, but Clang does.
Actual cases in real world code where I ran into this obviously won't have
quite this different structs, but do have structs that map to the exact same
layout.
I think this probably is reasonable to warn about though, given other cases
that both GCC and Clang warn about:
```c
typedef struct C {
int a;
} C;
typedef struct D {
int a;
} D;
C structfunc(int a) {
C ret;
ret.a = a;
return ret;
}
D structfuncalias(int a) __attribute__((alias("structfunc")));
```
---
I also did note that neither GCC nor Clang warns if the functions take
different types that are typedeffed to the same base type:
```c
typedef long long intmax_t;
intmax_t imaxfunc(intmax_t a) { return a; }
long long llfunc(long long a) __attribute__((alias("imaxfunc")));
```
So this applies to types, but differently named structs with identical contents
aren't considered equal. (If I change `typedef struct D { int a; } D;` above
into `typdef C D;`, then both GCC and Clang stop warning about it.)
See https://gcc.godbolt.org/z/W79cdcYTc for my comparison example in action.
https://github.com/llvm/llvm-project/pull/195550
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits