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

            Bug ID: 89122
           Summary: bad fix-it hint for FLT_MAX when <limits.h> is
                    included
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

In a program that refers to a macro like FLT_MAX or FLT_MIN with <limits.h> but
not <float.h> included GCC issues an error (as it should) but suggests
replacing the macros with INT_MAX or INT_MIN, respectively, instead of
suggesting to include the <float.h> header where the referenced macros are
defined.  (Clang doesn't do any better.)

$ cat x.c && gcc -O2 -S -Wall -Wextra -Wpedantic x.c
#include <limits.h>

float f = FLT_MAX;
x.c:3:11: error: ‘FLT_MAX’ undeclared here (not in a function); did you mean
‘INT_MAX’?
    3 | float f = FLT_MAX;
      |           ^~~~~~~
      |           INT_MAX

Reply via email to