This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Document behavior of __builtin_*_overflow_p on bitfields
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jason Merrill <jason at redhat dot com>, "Joseph S. Myers" <joseph at codesourcery dot com>, Marek Polacek <polacek at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 27 Jun 2016 20:19:42 +0200
- Subject: [PATCH] Document behavior of __builtin_*_overflow_p on bitfields
- Authentication-results: sourceware.org; auth=none
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
While the docs say that no integral argument promotions are performed, I
think it is better to make the behavior for bit-fields explicitly
documented.
Ok for trunk?
2016-06-27 Jakub Jelinek <jakub@redhat.com>
* doc/extend.texi (__builtin_add_overflow_p): Clarify behavior when
last argument is a bit-field.
--- gcc/doc/extend.texi.jj 2016-06-25 19:18:39.000000000 +0200
+++ gcc/doc/extend.texi 2016-06-27 13:58:34.209076739 +0200
@@ -9888,6 +9888,9 @@ cast to the type of the third argument.
precision result, the built-in functions return false, otherwise they return true.
The value of the third argument is ignored, just the side-effects in the third argument
are evaluated, and no integral argument promotions are performed on the last argument.
+If the third argument is a bit-field, the type used for the result cast has the
+precision and signedness of the given bit-field, rather than precision and signedness
+of the underlying type.
For example, the following macro can be used to portably check, at
compile-time, whether or not adding two constant integers will overflow,
Jakub