immunant / IA2-Phase2

5 stars 0 forks source link

runtime: use `__attribute__((__noreturn__))` instead of `_Noreturn` to avoid errors #431

Closed kkysen closed 1 month ago

kkysen commented 1 month ago

_Noreturn doesn't exist before C11, and is deprecated in C23 (in favor or [[noreturn]]), so it's simpler just to use __attribute__((__noreturn__)) since we don't know what C version the headers will be compiled with.

ayrtonm commented 1 month ago

I think we should replace our uses of _Noreturn with __attribute__((__noreturn__)) instead.

kkysen commented 1 month ago

I think we should replace our uses of _Noreturn with __attribute__((__noreturn__)) instead.

In all cases, or just pre C11?

ayrtonm commented 1 month ago

All cases. Glibc sometimes defines it as #define _Noreturn but I think that's just for old versions of gcc and unrecognized attributes should be ignored anyway. (Also I linked to our repo's glibc sysroot out of convenience but we don't use it on x86 in case that wasn't clear.)

kkysen commented 1 month ago

All cases. Glibc sometimes defines it as #define _Noreturn but I think that's just for old versions of gcc and unrecognized attributes should be ignored anyway. (Also I linked to our repo's glibc sysroot out of convenience but we don't use it on x86 in case that wasn't clear.)

Should I do something like #define _Noreturn __attribute__((__noreturn__)) or just use __attribute__((__noreturn__)) inline in each case (just more verbose I guess)?

Also, can I just use __attribute__((noreturn))? It should be identical semantically (unless noreturn is #defined), just shorter.

ayrtonm commented 1 month ago

I think __attribute__((__noreturn__)) inline is preferable since it has the lowest chance of breaking with different C libraries/compilers/unexpected macro definitions.