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

            Bug ID: 115738
           Summary: Analyzer misses printf-via-function pointer for
                    -Wanalyzer-unsafe-call-within-signal-handler
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: sjames at gcc dot gnu.org
  Target Milestone: ---

We should try to see through trivial function pointer assignment where we can.

We don't emit -Wanalyzer-unsafe-call-within-signal-handler here. I don't
_think_ pinskia's observation at
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115737#c1 affects this.

```
#include <signal.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int (*my_logger)(const char * restrict, ...);

void handle_the_signals() {
        my_logger("uh");
}

int main(void) {
        my_logger = &printf;
        signal(SIGSEGV, &handle_the_signals);
        raise(SIGSEGV);
}
```

(Note that I don't think this is too contrived, as the function pointer could
easily be assigned based on some debug variable or flag at runtime.)

Reply via email to