Re: [PATCH] enhance overflow and truncation detection in strncpy and strncat (PR 81117)

2017-08-09 Thread Jeff Law
On 08/06/2017 02:07 PM, Martin Sebor wrote: >>> >>> You're right that there is no truncation and the effect is >>> the same but only in the unlikely case when the destination >>> is empty. Otherwise the result is truncated. >> Maybe this is where I'm confused. How does the destination play into

Re: [PATCH] enhance overflow and truncation detection in strncpy and strncat (PR 81117)

2017-08-06 Thread Martin Sebor
On 08/02/2017 10:58 AM, Jeff Law wrote: On 07/31/2017 01:42 PM, Martin Sebor wrote: So I *think* TYPE_SIZE_UNIT isn't necessarily guaranteed to be a INTEGER_CST, it could be a non-constant expression for the size. Are the callers of compute_objsize prepared to handle that? Just to be clear,

Re: [PATCH] enhance overflow and truncation detection in strncpy and strncat (PR 81117)

2017-08-02 Thread Jeff Law
On 07/31/2017 01:42 PM, Martin Sebor wrote: >> So I *think* TYPE_SIZE_UNIT isn't necessarily guaranteed to be a >> INTEGER_CST, it could be a non-constant expression for the size. Are >> the callers of compute_objsize prepared to handle that? Just to be >> clear, I'd prefer to return

Re: [PATCH] enhance overflow and truncation detection in strncpy and strncat (PR 81117)

2017-07-31 Thread Martin Sebor
So I think the fixes exposed by the new warning are OK to go in as-is immediately if you wish to do so. Minor questions on the actual improved warnings inline. Sure, thanks. -static inline tree +static tree compute_objsize (tree dest, int ostype) { ... + type = TYPE_MAIN_VARIANT

Re: [PATCH] enhance overflow and truncation detection in strncpy and strncat (PR 81117)

2017-07-31 Thread Jeff Law
On 07/08/2017 02:45 PM, Martin Sebor wrote: > PR 81117 asks for improved detection of common misuses(*) of > strncpy and strncat. The attached patch is my solution. It > consists of three related sets of changes: > > 1) Adds a new option, -Wstringop-truncation, that diagnoses calls > to