Re: memset zero bytes at NULL - isolate-erroneous-paths

2013-11-19 Thread Richard Biener
On Mon, Nov 18, 2013 at 3:24 PM, Jeff Law wrote: > On 11/18/13 04:08, Richard Biener wrote: >>> >>> I'd say that turning memset (0, '\0', 0) into a trap is bad from a QOI >> >> perspective. Jeff, is there an easy way to avoid this? Testcase: >> >> void fn (void *addr, int a) >> { >>if (a ==

Re: memset zero bytes at NULL - isolate-erroneous-paths

2013-11-18 Thread Ondřej Bílka
On Mon, Nov 18, 2013 at 07:24:46AM -0700, Jeff Law wrote: > On 11/18/13 04:08, Richard Biener wrote: > >>I'd say that turning memset (0, '\0', 0) into a trap is bad from a QOI > >perspective. Jeff, is there an easy way to avoid this? Testcase: > > > >void fn (void *addr, int a) > >{ > > if (a =

Re: memset zero bytes at NULL - isolate-erroneous-paths

2013-11-18 Thread Jeff Law
On 11/18/13 04:08, Richard Biener wrote: I'd say that turning memset (0, '\0', 0) into a trap is bad from a QOI perspective. Jeff, is there an easy way to avoid this? Testcase: void fn (void *addr, int a) { if (a == 0) addr = (void *)0; __builtin_memset (addr, '\0', a); } I wonder

Re: memset zero bytes at NULL - isolate-erroneous-paths

2013-11-18 Thread Jakub Jelinek
On Mon, Nov 18, 2013 at 12:08:27PM +0100, Richard Biener wrote: > I'd say that turning memset (0, '\0', 0) into a trap is bad from a QOI > perspective. Jeff, is there an easy way to avoid this? Testcase: > > void fn (void *addr, int a) > { > if (a == 0) > addr = (void *)0; > __builtin_me

Re: memset zero bytes at NULL - isolate-erroneous-paths

2013-11-18 Thread Richard Biener
On Mon, Nov 18, 2013 at 8:11 AM, Florian Weimer wrote: > * Jeff Law: > >>> Is this new in C11? Does it apply to functions such as strnlen as well? > >> No, it's C99 I think. There was a clarification which came in after >> C99 which clarified that even if the length is zero, the pointers must >>

Re: memset zero bytes at NULL - isolate-erroneous-paths

2013-11-17 Thread Florian Weimer
* Jeff Law: >> Is this new in C11? Does it apply to functions such as strnlen as well? > No, it's C99 I think. There was a clarification which came in after > C99 which clarified that even if the length is zero, the pointers must > still be valid. Okay, I found the language in sections 7.1.4 a

Re: memset zero bytes at NULL - isolate-erroneous-paths

2013-11-17 Thread Jeff Law
On 11/17/13 15:02, Florian Weimer wrote: * Jonathan Wakely: On 17 November 2013 18:25, Dominic News wrote: In the following code (from xorg-server) if (a == 0) addr = 0; (...) memset(addr, '\0', a); the path for a==0 is turned into a trap by -fisolate-erroneous-paths.

Re: memset zero bytes at NULL - isolate-erroneous-paths

2013-11-17 Thread Marc Glisse
On Sun, 17 Nov 2013, Florian Weimer wrote: * Jonathan Wakely: On 17 November 2013 18:25, Dominic News wrote: In the following code (from xorg-server) if (a == 0) addr = 0; (...) memset(addr, '\0', a); the path for a==0 is turned into a trap by -fisolate-erroneous-paths.

Re: memset zero bytes at NULL - isolate-erroneous-paths

2013-11-17 Thread Florian Weimer
* Jonathan Wakely: > On 17 November 2013 18:25, Dominic News wrote: >> In the following code (from xorg-server) >> >> if (a == 0) >> addr = 0; >> (...) >> memset(addr, '\0', a); >> >> the path for a==0 is turned into a trap by -fisolate-erroneous-paths. (Is >> calling memset li

Re: memset zero bytes at NULL - isolate-erroneous-paths

2013-11-17 Thread Jonathan Wakely
On 17 November 2013 18:25, Dominic News wrote: > In the following code (from xorg-server) > > if (a == 0) > addr = 0; > (...) > memset(addr, '\0', a); > > the path for a==0 is turned into a trap by -fisolate-erroneous-paths. (Is > calling memset like this undefined behaviour?)

memset zero bytes at NULL - isolate-erroneous-paths

2013-11-17 Thread Dominic News
In the following code (from xorg-server) if (a == 0) addr = 0; (...) memset(addr, '\0', a); the path for a==0 is turned into a trap by -fisolate-erroneous-paths. (Is calling memset like this undefined behaviour?) Is it intentional that essentially a noop is turned into a trap?