diff mbox

[2/4] enhance overflow and truncation detection in strncpy and strncat (PR 81117)

Message ID b0d80bf1-a1a6-1dd2-e927-4f1aa34c4c5e@gmail.com
State New
Headers show

Commit Message

Martin Sebor Aug. 14, 2017, 8:06 p.m. UTC
On 08/14/2017 01:50 PM, Joseph Myers wrote:
> On Mon, 14 Aug 2017, Martin Sebor wrote:
>
>>  /* This header provides a declarative way of describing the attributes
>> -   that are applied to some functions by default.
>> +   that are applied to some built-in functions by default.  Attributes
>> +   that apply to types or variables but not functions need not and
>> +   should not be defined here.
>
> It's not just type and variable attributes that shouldn't be here.  Any
> function attribute that's not used by at least one built-in function
> shouldn't be here either.  Every tree constructed here adds to startup
> costs; they should only be present if actually used.

Okay.  I expanded on that point in the updated comments below.

Martin

2017-08-14  Martin Sebor  <msebor@redhat.com>

     * builtin-attrs.def: Add comments.

Comments

Joseph Myers Aug. 14, 2017, 9:08 p.m. UTC | #1
On Mon, 14 Aug 2017, Martin Sebor wrote:

> Okay.  I expanded on that point in the updated comments below.
> 
> Martin
> 
> 2017-08-14  Martin Sebor  <msebor@redhat.com>
> 
>     * builtin-attrs.def: Add comments.

This version is OK.
diff mbox

Patch

Index: gcc/builtin-attrs.def
===================================================================
--- gcc/builtin-attrs.def	(revision 251097)
+++ gcc/builtin-attrs.def	(working copy)
@@ -18,7 +18,10 @@  along with GCC; see the file COPYING3.  If not see
  <http://www.gnu.org/licenses/>.  */

  /* This header provides a declarative way of describing the attributes
-   that are applied to some functions by default.
+   that are applied to some built-in functions by default.  Attributes
+   that are meant to be used by user-defined functions but aren't used
+   by any built-ins, or attributes that apply to types or variables
+   but not to functions need not and should not be defined here.

     Before including this header, you must define the following macros.
     In each case where there is an ENUM, it is an identifier used to
@@ -85,7 +88,9 @@  DEF_LIST_INT_INT (5,0)
  DEF_LIST_INT_INT (5,6)
  #undef DEF_LIST_INT_INT

-/* Construct trees for identifiers.  */
+/* Construct trees for identifiers used in built-in function attributes.
+   The construction contributes to startup costs so only attributes that
+   are used to define built-ins should be defined here.  */
  DEF_ATTR_IDENT (ATTR_ALLOC_SIZE, "alloc_size")
  DEF_ATTR_IDENT (ATTR_COLD, "cold")
  DEF_ATTR_IDENT (ATTR_CONST, "const")