[Bug c/71479] error on __builtin_add_overflow with bool or enum pointer as last argument

2017-02-15 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71479

--- Comment #7 from Martin Sebor  ---
Wrong dupe id.

*** This bug has been marked as a duplicate of bug 66938 ***

[Bug c/71479] error on __builtin_add_overflow with bool or enum pointer as last argument

2017-02-15 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71479

Martin Sebor  changed:

   What|Removed |Added

   Keywords|rejects-valid   |diagnostic
 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |DUPLICATE
  Known to fail|7.0 |

--- Comment #6 from Martin Sebor  ---
Resolving as a dupe of 66943 (the error is correct).

Trunk (GCC 7.0) prints:

t.c: In function ‘f’:
t.c:4:33: error: argument 3 in call to function ‘__builtin_add_overflow’ has
pointer to boolean type
   __builtin_add_overflow (0, 0, );
 ^
t.c:7:33: error: argument 3 in call to function ‘__builtin_add_overflow’ has
pointer to enumerated type
   __builtin_add_overflow (0, 0, );
 ^

*** This bug has been marked as a duplicate of bug 66943 ***

[Bug c/71479] error on __builtin_add_overflow with bool or enum pointer as last argument

2016-06-10 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71479

--- Comment #5 from Jakub Jelinek  ---
BTW, for __builtin_add_overflow_p with _Bool as last argument (which isn't
rejected, going to fix that momentarily) we don't emit the expected test
whether the result is 0/1, but whether it fits 8 bits unsigned.  Also, _Complex
_Bool
or _Complex enum ... is something way too weird for the middle-end.

[Bug c/71479] error on __builtin_add_overflow with bool or enum pointer as last argument

2016-06-10 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71479

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek  ---
I see that in __builtin_*_overflow_p I'm actually checking just INTEGRAL_TYPE_P
rather than INTEGER_TYPE for the last argument.
But, I think I'm in favor of tweaking the documentation and only allowing for
*_overflow pointer to T, for *_overflow_p T, where T is integral type other
than boolean or enumeration type.
While for _Bool/bool, it is not that hard to define what exactly it would mean
(check if the infinite precision result is 0 or 1 or not), for enums, would we
check if it fits into the underlying type, or fits into the strict precision of
the enum, have different behavior based on -fstrict-enums, or check if there is
any enumerator at that point, ... ?

[Bug c/71479] error on __builtin_add_overflow with bool or enum pointer as last argument

2016-06-09 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71479

--- Comment #3 from Martin Sebor  ---
(In reply to Marek Polacek from comment #1)
> Dup of PR66938?

You're right, bug 66938 points out the same problem.  I leave it to you to
decide which one to close as a dupe (this one is broader in mentioning
enumerated types as well and has a test case so I'd be inclined to keep it
open.)

[Bug c/71479] error on __builtin_add_overflow with bool or enum pointer as last argument

2016-06-09 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71479

Martin Sebor  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  ---
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, );

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

  char c;
  __builtin_add_overflow (0, 0, );
}
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, );
   ^~
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, );
   ^~

[Bug c/71479] error on __builtin_add_overflow with bool or enum pointer as last argument

2016-06-09 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71479

Marek Polacek  changed:

   What|Removed |Added

 CC||mpolacek at gcc dot gnu.org

--- Comment #1 from Marek Polacek  ---
Dup of PR66938?