Re:Proposal for a Friendly Dialect of C
by DSMan195276 on Wednesday August 27, 2014 @03:58PM
(#8234424)
If you don't mind me taking a guess, is it because calling memcpy with NULL is undefined-behavior, thus GCC assumes p must be non-null and thus the if (p) is redundant and x must equal 1?
[ Parent
| on HN ]
Re:Proposal for a Friendly Dialect of C
by pascal_cuoq on Wednesday August 27, 2014 @04:08PM
(#8234466)
Exactly. Propagating the information that p was passed as argument to memcpy and thus must be non-null is a new GCC 4.9 optimization (some discussion here: http://stackoverflow.com/questions/5243012/is-it-guaranteed-... ).