[clang] Diagnose problematic uses of constructor/destructor attribute (PR #67360)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 27 11:47:16 PDT 2023


AaronBallman wrote:

> > We could maybe presume glibc on ELF targets
> 
> Isn't that part of the triple? `aarch64-linux-gnu` gnu -> glibc (as opposed to `aarch64-linux-musl` -> musl, or `aarch64-linux-android` -> bionic)

Oh -- I wasn't aware we tracked that in the triple, that's awesome! I'll give that a shot.

> Hopefully the number of constructors that expect getting arguments is extremely rare. But I do worry that there is code out there that assumes glibc behaviour, so it seems to me that err_ctor_dtor_attr_on_non_void_func needs to be a warning-as-error that can be downgraded?

Hopefully we can avoid emitting the diagnostic at all for glibc, then we can leave it as a hard error for the other cases. My concern about turning that into a warning which defaults to an error is that a less thorough programmer may shut the warning up rather than realize their CRT doesn't support that.

https://github.com/llvm/llvm-project/pull/67360


More information about the cfe-commits mailing list