https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88954

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
My question is about the change you are proposing.  How do you expect g() to be
called if the test case from comment #0 is modified for example as follows:

  void f_plt(void);
  void f_noplt(void) __attribute__((noplt));
  void (*p_noplt)(void) = f_noplt;
  void g(void (*)(void));

  int main()
  {
    if (getenv ("USE_PLT"))
      p_noplt = f_plt;   // should this be diagnosed?

    g (p_noplt);
  }

In most other cases, initializing a pointer with the address of a function
declared with some function attribute (e.g., const, nonnull, noreturn, pure, or
warn_unused_result) doesn't transfer the special properties to the pointer, so
I'm trying to understand what semantics you are after and if there is any
potential for user errors and decide whether they should be detected.

I happen to think it would make sense to make it possible to imbue function
pointers with some (but not all) of the same attributes as those that apply to
functions, but there certainly are cases where doing so could cause problems,
just as there are cases where not doing so can.

Reply via email to