https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84210
--- Comment #2 from Andrey Ryabinin <ryabinin.a.a at gmail dot com> --- (In reply to Richard Biener from comment #1) > Confirmed. Note that I'm not sure it makes no sense - it just means the > function has no side-effect besides not returning ;) > Well, GCC docs say that const functions "have no effects except to return a value" and "It does not make sense for a const function to return void." I suppose that noreturn functions fells into the same category here as return void functions. Besides, __ubsan_handle_builtin_unreachable() does have side-effect, it prints error. > lib/ubsan.c is from the kernel I guess where you "copy" the attributes from > sanitizer.def? > Yes, lib/ubsan.c is kernel's implementation of libubsan. We don't exactly 'copy' attributes, but __ubsan_handle_builtin_unreachable() does have noreturn. I've tried to add const to be consistent with GCC, but it become only worse: ../lib/ubsan.c:432:1: warning: ignoring attribute ‘noreturn’ in declaration of a built-in function ‘__ubsan_handle_builtin_unreachable’ because it conflicts with attribute ‘const’ [-Wattributes] { ^ <built-in>: note: previous declaration here ../lib/ubsan.c:432:1: warning: ‘const’ attribute on function returning ‘void’ [-Wattributes] ../lib/ubsan.c:432:1: warning: ignoring attribute ‘const’ in declaration of a built-in function ‘__ubsan_handle_builtin_unreachable’ because it conflicts with attribute ‘noreturn’ [-Wattributes] <built-in>: note: previous declaration here > GCC internally could also use "no vops" but you couldn't replicate that. > We probably don't have to replicate all attributes. At least userspace libubsan doesn't do that at all. In fact we could workaround this warning simply by dropping noreturn: http://lkml.kernel.org/r/20180202154813.1625742-1-a...@arndb.de But, I'm thinking that there is something wrong in GCC, hence filed this bug. > Not sure if it is/was important to have the function 'const'.