Re: Re: svn commit: r241373 - head/lib/libc/stdlib

2012-10-11 Thread Kevin Lo
On 2012/10/12 03:50, Eitan Adler wrote: On 11 October 2012 07:44, Pawel Jakub Dawidek wrote: On Tue, Oct 09, 2012 at 01:51:05PM -0400, Eitan Adler wrote: On 9 October 2012 13:27, wrote: The original behavior can be recovered by using inline assembly to fetch the value from a register into a

Re: svn commit: r241373 - head/lib/libc/stdlib

2012-10-11 Thread Eitan Adler
On 11 October 2012 07:44, Pawel Jakub Dawidek wrote: > On Tue, Oct 09, 2012 at 01:51:05PM -0400, Eitan Adler wrote: >> On 9 October 2012 13:27, wrote: >> > The original behavior can be recovered by using inline assembly to >> > fetch the value from a register into a local C variable; this would

Re: svn commit: r241373 - head/lib/libc/stdlib

2012-10-11 Thread Andrey Chernov
On 11.10.2012 19:23, Peter Wemm wrote: > On Thu, Oct 11, 2012 at 6:14 AM, Andrey Chernov wrote: >> On 11.10.2012 15:44, Pawel Jakub Dawidek wrote: >>> On Tue, Oct 09, 2012 at 01:51:05PM -0400, Eitan Adler wrote: On 9 October 2012 13:27, wrote: > The original behavior can be recovered by

Re: svn commit: r241373 - head/lib/libc/stdlib

2012-10-11 Thread Peter Wemm
On Thu, Oct 11, 2012 at 6:14 AM, Andrey Chernov wrote: > On 11.10.2012 15:44, Pawel Jakub Dawidek wrote: >> On Tue, Oct 09, 2012 at 01:51:05PM -0400, Eitan Adler wrote: >>> On 9 October 2012 13:27, wrote: The original behavior can be recovered by using inline assembly to fetch the valu

Re: svn commit: r241373 - head/lib/libc/stdlib

2012-10-11 Thread Andrey Chernov
On 11.10.2012 15:44, Pawel Jakub Dawidek wrote: > On Tue, Oct 09, 2012 at 01:51:05PM -0400, Eitan Adler wrote: >> On 9 October 2012 13:27, wrote: >>> The original behavior can be recovered by using inline assembly to >>> fetch the value from a register into a local C variable; this would at >>> l

Re: svn commit: r241373 - head/lib/libc/stdlib

2012-10-11 Thread Pawel Jakub Dawidek
On Tue, Oct 09, 2012 at 01:51:05PM -0400, Eitan Adler wrote: > On 9 October 2012 13:27, wrote: > > The original behavior can be recovered by using inline assembly to > > fetch the value from a register into a local C variable; this would at > > least not rely on undefined behavior. But I agree i

Re: svn commit: r241373 - head/lib/libc/stdlib

2012-10-09 Thread Steve Kargl
On Tue, Oct 09, 2012 at 06:06:55PM -0400, Eitan Adler wrote: > On 9 October 2012 17:25, Steve Kargl > wrote: > > ... yes, I was misreading the text. > > > Clang has no way of determining if 'a' is initialized or not. > > If David is correct that 'junk' is optimized out by clang/llvm, > > then i

Re: svn commit: r241373 - head/lib/libc/stdlib

2012-10-09 Thread Eitan Adler
On 9 October 2012 18:06, Eitan Adler wrote: > On 9 October 2012 17:25, Steve Kargl > wrote: > > ... yes, I was misreading the text. > >> Clang has no way of determining if 'a' is initialized or not. >> If David is correct that 'junk' is optimized out by clang/llvm, >> then it seems that clang vi

Re: svn commit: r241373 - head/lib/libc/stdlib

2012-10-09 Thread Eitan Adler
On 9 October 2012 17:25, Steve Kargl wrote: ... yes, I was misreading the text. > Clang has no way of determining if 'a' is initialized or not. > If David is correct that 'junk' is optimized out by clang/llvm, > then it seems that clang violates footnote 116. Yes, I know > it is non-normative t

Re: svn commit: r241373 - head/lib/libc/stdlib

2012-10-09 Thread Steve Kargl
On Tue, Oct 09, 2012 at 04:23:59PM -0400, Eitan Adler wrote: > On 9 October 2012 14:24, Andrey Chernov wrote: > > I don't have ISO9899 nearby, could you directly quote mentioned > > sections, please? > > Accesses to volatile object (a) produce side effects (b) have > implementation defined values

Re: svn commit: r241373 - head/lib/libc/stdlib

2012-10-09 Thread Eitan Adler
On 9 October 2012 14:24, Andrey Chernov wrote: > I don't have ISO9899 nearby, could you directly quote mentioned > sections, please? Accesses to volatile object (a) produce side effects (b) have implementation defined values. A more careful re-reading of the relevant section leads me to believe

Re: svn commit: r241373 - head/lib/libc/stdlib

2012-10-09 Thread Andrey Chernov
On 09.10.2012 21:47, Eitan Adler wrote: > On 9 October 2012 12:33, Andrey Chernov wrote: >> Do you check assembler output for _both_ cases? > > Yes. ... > http://blog.eitanadler.com/2012/10/reduced-entropy-in-rand-and-random.html At this URL I see only already known buggy assembler without 'vola

Re: svn commit: r241373 - head/lib/libc/stdlib

2012-10-09 Thread Eitan Adler
On 9 October 2012 13:16, David Chisnall wrote: > On 9 Oct 2012, at 17:33, Andrey Chernov wrote: > >> Do you check assembler output for _both_ cases? >> In my testing clang and gcc xor's 'junk' properly in case it have >> 'volatile' keyword (as in srandomdev()) and elide it without 'volatile'. >> I

Re: svn commit: r241373 - head/lib/libc/stdlib

2012-10-09 Thread Eitan Adler
On 9 October 2012 13:27, wrote: > The original behavior can be recovered by using inline assembly to > fetch the value from a register into a local C variable; this would at > least not rely on undefined behavior. But I agree it's of dubious > value anyways. I proposed this (with a patch). We w

Re: svn commit: r241373 - head/lib/libc/stdlib

2012-10-09 Thread Eitan Adler
On 9 October 2012 12:33, Andrey Chernov wrote: > Do you check assembler output for _both_ cases? Yes. > In my testing clang and gcc xor's 'junk' properly in case it have > 'volatile' keyword (as in srandomdev()) and elide it without 'volatile'. volatile is still undefined: see 5.1.2.2.3 and 6.7

Re: svn commit: r241373 - head/lib/libc/stdlib

2012-10-09 Thread mdf
On Tue, Oct 9, 2012 at 10:16 AM, David Chisnall wrote: > On 9 Oct 2012, at 17:33, Andrey Chernov wrote: > >> Do you check assembler output for _both_ cases? >> In my testing clang and gcc xor's 'junk' properly in case it have >> 'volatile' keyword (as in srandomdev()) and elide it without 'volatil

Re: svn commit: r241373 - head/lib/libc/stdlib

2012-10-09 Thread David Chisnall
On 9 Oct 2012, at 17:33, Andrey Chernov wrote: > Do you check assembler output for _both_ cases? > In my testing clang and gcc xor's 'junk' properly in case it have > 'volatile' keyword (as in srandomdev()) and elide it without 'volatile'. > IMHO this change should be backed out for srandomdev() a

Re: svn commit: r241373 - head/lib/libc/stdlib

2012-10-09 Thread Andrey Chernov
Do you check assembler output for _both_ cases? In my testing clang and gcc xor's 'junk' properly in case it have 'volatile' keyword (as in srandomdev()) and elide it without 'volatile'. IMHO this change should be backed out for srandomdev() and adding 'volatile' for sranddev() instead. On 09.10.2