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

            Bug ID: 70883
           Summary: inconsistent error message for calls to
                    __builtin_add_overflow with too few arguments
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

This is a just a minor issue but it's one that I noticed when my newly written
new tests for the __builtin_op_overflow functions were failing.  It turned out
that the failures were due to the assumption that GCC would diagnose the same
problem (insufficient number of arguments) using the same diagnostic.  The test
case below shows that GCC uses one spelling ("not enough arguments") for the
error caused by calls to the type-generic __builtin_add_overflow and a
different spelling ("too few arguments") for the same error for
__builtin_sadd_overflow and the rest.  Both C and C++ front ends have this
inconsistency.  It seems like the second spelling is more prevalent and should
be used for consistency.

$ cat x.cpp && gcc -Wall -Wextra -Wpedantic -xc x.cpp
void f (int a)
{
  __builtin_add_overflow (a);
  __builtin_sadd_overflow (a);
}

void g (void)
{
    f ();
}
x.cpp: In function ‘f’:
x.cpp:3:3: error: not enough arguments to function ‘__builtin_add_overflow’
   __builtin_add_overflow (a);
   ^~~~~~~~~~~~~~~~~~~~~~
x.cpp:4:3: error: too few arguments to function ‘__builtin_sadd_overflow’
   __builtin_sadd_overflow (a);
   ^~~~~~~~~~~~~~~~~~~~~~~
x.cpp: In function ‘g’:
x.cpp:9:5: error: too few arguments to function ‘f’
     f ();
     ^
x.cpp:1:6: note: declared here
 void f (int a)
      ^

Reply via email to