[Bug c++/67767] New: -Wsuggest-attribute=noreturn suggests noreturn for function which already has noreturn and cold.
zerotype at yahoo dot com
gcc-bugzilla@gcc.gnu.org
Tue Sep 29 14:38:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67767
Bug ID: 67767
Summary: -Wsuggest-attribute=noreturn suggests noreturn for
function which already has noreturn and cold.
Product: gcc
Version: 5.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: zerotype at yahoo dot com
Target Milestone: ---
(Observed in Ubuntu builds of g++ 4.9.2 and 5.1.0)
I have a class containing various function pointers which are initialised
depending on command-line parameters specified by the user. To catch any bugs
which could result in one of the pointers not pointing to a valid function, the
class's constructor normally default-initialises them to point to functions
which throw exceptions - like so:
//header file containing declaration:
> typedef void (*objfunc_entity_specific_assignment_function) (objective_function_struct& ofs, gmips_entity_specific_information_struct& gesis, const sbox_size_object& sso);
> void entity_specific_assignment_function_not_set [[gnu::cold, gnu::noreturn]] (objective_function_struct& ofs, gmips_entity_specific_information_struct& gesis, const sbox_size_object& sso);
//cpp file:
> void entity_specific_assignment_function_not_set(objective_function_struct& ofs, gmips_entity_specific_information_struct& gesis, const sbox_size_object& sso)
> {
> throw misc_exception(__FILE__" " + std::string(__PRETTY_FUNCTION__) + " called.\n");
> }
Before I added the gnu::cold attribute, compiling with
-Wsuggest-attribute=noreturn did not result in the noreturn attribute being
suggested, because of course the function already had it. After changing from
[[gnu::noreturn]] to [[gnu::cold, gnu::noreturn]] I get:
> warning: function might be candidate for attribute ‘noreturn’ [-Wsuggest-attribute=noreturn]
> void entity_specific_assignment_function_not_set(objective_function_struct& ofs, gmips_entity_specific_information_struct& gesis, const sbox_size_object&
> ^
More information about the Gcc-bugs
mailing list