sudo-project / sudo

Utility to execute a command as another user
https://www.sudo.ws
Other
1.16k stars 208 forks source link

sudo_fatal: Fix build where compiler recognises [[noreturn]] attribut… #240

Closed thesamesam closed 1 year ago

thesamesam commented 1 year ago

If the compiler supports [[noreturn]] as a attribute as in C23, then we define sudo_noreturn to be it. When that's the case, we must place it at the beginning of the declaration, before any other extension attributes (__attribute(...)).

sudo_dso_public is always an extension attribute, while sudo_noreturn only might be, so put it first.

This only shows up with GCC 13 so far (see the linked GCC bug (notabug) for a bit more exploration). Clang 16 does support the attribute but doesn't let you sue it for earlier language versions (need to pass explicit -std=c2x, unlike with GCC here).

This is essentially a followup to e707ffe58b3ccfe5c72f54c38eac1d7069d5021e.

Tested with GCC 13.0.1 20230212 (unreleased), GCC 12.2.1 20230211, Clang 16.0.0_rc2, and Clang 15.0.7.

Bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108796 Closes: https://github.com/sudo-project/sudo/issues/239 Fixes: e707ffe58b3ccfe5c72f54c38eac1d7069d5021e Fixes: 16ae61dcd7d3cd8bf6eb10a22fa742d4505da4e9

millert commented 1 year ago

Thanks for tracking that down, the required ordering of C23 attributes is a bit of a trap.

thesamesam commented 1 year ago

No worries, appreciate the quick merge too!