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, m...@freebsd.org 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

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 a...@freebsd.org 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, m...@freebsd.org wrote: The original behavior

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

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() and

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

2012-10-09 Thread mdf
On Tue, Oct 9, 2012 at 10:16 AM, David Chisnall thera...@freebsd.org 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

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

2012-10-09 Thread Eitan Adler
On 9 October 2012 12:33, Andrey Chernov a...@freebsd.org 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

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

2012-10-09 Thread Eitan Adler
On 9 October 2012 13:27, m...@freebsd.org 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

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

2012-10-09 Thread Eitan Adler
On 9 October 2012 13:16, David Chisnall thera...@freebsd.org 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

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 a...@freebsd.org 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

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

2012-10-09 Thread Eitan Adler
On 9 October 2012 14:24, Andrey Chernov a...@freebsd.org 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

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 a...@freebsd.org 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

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

2012-10-09 Thread Eitan Adler
On 9 October 2012 17:25, Steve Kargl s...@troutmask.apl.washington.edu 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,

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

2012-10-09 Thread Eitan Adler
On 9 October 2012 18:06, Eitan Adler ead...@freebsd.org wrote: On 9 October 2012 17:25, Steve Kargl s...@troutmask.apl.washington.edu 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

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 s...@troutmask.apl.washington.edu 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