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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
      Known to fail|                            |4.9.3, 5.3.0, 6.1.0, 7.0

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
The three type-generic Built-in Functions to Perform Arithmetic with Overflow
Checking document their interface like so:

  The first built-in function allows arbitrary integral types for operands and
the result type must be pointer to some integer type, ...

The C and C++ standard term /integer type/ encompasses both _Bool and
enumerated types, in addition to signed and unsigned integer types.

Give this, one should expect __builtin_add_overflow to accept a pointer to any
one of these types as the last argument.  However, GCC rejects such calls. 
Either the documentation should be clarified or the argument checking adjusted
to match the existing text.  (I would lean toward accepting _Bool but
continuing to reject enumerated types, especially in C++.)

$ cat z.cpp && /home/msebor/build/gcc-6-branch/gcc/xgcc -B
/home/msebor/build/gcc-6-branch/gcc/ -Wall -Wextra -xc z.cpp
void f (void)
{
  _Bool b;
  __builtin_add_overflow (0, 0, &b);

  enum E { e0 } e;
  __builtin_add_overflow (0, 0, &e);

  char c;
  __builtin_add_overflow (0, 0, &c);
}
z.cpp: In function ‘f’:
z.cpp:4:3: error: argument 3 in call to function ‘__builtin_add_overflow’ does
not have pointer to integer type
   __builtin_add_overflow (0, 0, &b);
   ^~~~~~~~~~~~~~~~~~~~~~
z.cpp:7:3: error: argument 3 in call to function ‘__builtin_add_overflow’ does
not have pointer to integer type
   __builtin_add_overflow (0, 0, &e);
   ^~~~~~~~~~~~~~~~~~~~~~

Reply via email to