This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/71479] error on __builtin_add_overflow with bool or enum pointer as last argument
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 09 Jun 2016 17:56:55 +0000
- Subject: [Bug c/71479] error on __builtin_add_overflow with bool or enum pointer as last argument
- Auto-submitted: auto-generated
- References: <bug-71479-4 at http dot gcc dot gnu dot org/bugzilla/>
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);
^~~~~~~~~~~~~~~~~~~~~~