nihstro icon indicating copy to clipboard operation
nihstro copied to clipboard

Avoid void return in non-void function

Open scarabeusiv opened this issue 5 years ago • 2 comments

This allows the app to compile on gcc with hardening (SUSE).

scarabeusiv avatar Sep 30 '20 09:09 scarabeusiv

I'm not a fan of introducing code like this just to fix compiler warnings that are false-positives. Would builtin_unreachable (hidden behind an NIHSTRO_UNREACHABLE macro defined at the top of the file so it doesn't break the msvc build) work with your compiler too?

neobrain avatar Sep 30 '20 13:09 neobrain

It is not a specific in a form of a patch for SUSE. We just enforce -werror=return-type as it leads otherwise to quite bad behaviour if that unreachable case happens.

I guess it can be also safeguarded by the __builtin_unreachable() prior the return to make it obvious it never hits.

scarabeusiv avatar Sep 30 '20 13:09 scarabeusiv

If -werror=return-type compiles we can close this issue.

prprprpony avatar Jun 12 '23 07:06 prprprpony

If there's still action needed, please update the PR with the suggested builtin_unreachable changes. Closing for now.

As a general note, the recommendation is to include nihstro as a system header to suppress false warnings like this. (This may not be an option for Linux packaging, of course)

neobrain avatar Jul 11 '23 16:07 neobrain