Search found 692 matches

by rbarreira
Wed Dec 11, 2013 4:03 pm
Forum: Computer Chess Club: Programming and Technical Discussions
Topic: How could a compiler break the lockless hashing method?
Replies: 312
Views: 33756

Re: How could a compiler break the lockless hashing method?

I thought someone had already pointed out that shifting a negative value left is "undefined behavior"? But if a shift is dangerous, don't do it. Do the imul which works correctly. Or, of course, you can do a shld. BTW what do you know about (say) SAL and SHL? :) Shifting left is fine, it's right sh...
by rbarreira
Wed Dec 11, 2013 2:59 pm
Forum: Computer Chess Club: Programming and Technical Discussions
Topic: How could a compiler break the lockless hashing method?
Replies: 312
Views: 33756

Re: How could a compiler break the lockless hashing method?

For example, the x * 2 / 2 example does NOT overflow on x86 if done right, and it produces X every time, exactly as it should, no clever optimizer needed. So why not do that. Because that would mean changing the standard to f*** up the whole type system. If "x" is a 32-bit int then "x * 2" is also ...
by rbarreira
Wed Dec 11, 2013 1:55 pm
Forum: Computer Chess Club: Programming and Technical Discussions
Topic: How could a compiler break the lockless hashing method?
Replies: 312
Views: 33756

Re: How could a compiler break the lockless hashing method?

Sorry, but do you know x86 asm? movw $20000, %ax imulw 2 idivw 2 result = 20000 Exactly what I expected. No idea what machine you are running on, but on x86, multiply 2 16 bit ints, you get a 32 bit int; Then the divide hopefully reduces it back to a 16 bit int, otherwise the overflow flag is set. ...
by rbarreira
Wed Dec 11, 2013 1:35 pm
Forum: Computer Chess Club: Programming and Technical Discussions
Topic: How could a compiler break the lockless hashing method?
Replies: 312
Views: 33756

Re: How could a compiler break the lockless hashing method?

For example, the x * 2 / 2 example does NOT overflow on x86 if done right, and it produces X every time, exactly as it should, no clever optimizer needed. So why not do that. Because that would mean changing the standard to fuck up the whole type system. If "x" is a 32-bit int then "x * 2" is also ...
by rbarreira
Wed Dec 11, 2013 1:05 am
Forum: Computer Chess Club: General Topics
Topic: King Krusher Analysis of Boris Ivanov Game
Replies: 21
Views: 4609

Re: King Krusher Analysis of Boris Ivanov Game

Interesting analysis, but Ivanov often did not play Stockfish's top choice. Stockfish has a very different eval than other programs and often its scores are higher. If he has some kind of direct feed from a program, it appears the engine on the other end is not Stockfish. --Jon If I was cheating I'...
by rbarreira
Wed Dec 11, 2013 12:38 am
Forum: Computer Chess Club: Programming and Technical Discussions
Topic: How could a compiler break the lockless hashing method?
Replies: 312
Views: 33756

Re: How could a compiler break the lockless hashing method?

I've been programming since 1968. I've used integer overflow so many times (ever seen a linear congruential PRNG as just one example) and they have worked flawlessly. Now some compiler guys have decided that since it is undefined, even though it is an established and working programming paradigm, t...
by rbarreira
Tue Dec 10, 2013 10:39 pm
Forum: Computer Chess Club: Programming and Technical Discussions
Topic: How could a compiler break the lockless hashing method?
Replies: 312
Views: 33756

Re: How could a compiler break the lockless hashing method?

They don't really want to break your code just to be malicious. Then they must be incredibly incompetent. Because exiting with an error message when they detect a strcpy that would otherwise perfectly work, and for which they could see that it would perfectly work, does actually count as malicious ...
by rbarreira
Tue Dec 10, 2013 6:47 pm
Forum: Computer Chess Club: Programming and Technical Discussions
Topic: How could a compiler break the lockless hashing method?
Replies: 312
Views: 33756

Re: How could a compiler break the lockless hashing method?

I think you are confusing an unknown/undefined value with undefined behaviour. The latter is a technical term with a specific, well-defined, meaning. Reading a volatile variable isn't UB. Well, it was said somewhere that race conditions are mentioned in the standard as a form of undefined behavior,...
by rbarreira
Tue Dec 10, 2013 6:39 pm
Forum: Computer Chess Club: Programming and Technical Discussions
Topic: How could a compiler break the lockless hashing method?
Replies: 312
Views: 33756

Re: How could a compiler break the lockless hashing method?

Yeah that came out wrong. What I should have said is that the mere potential for a data race is not undefined. Only an actual race is.
by rbarreira
Tue Dec 10, 2013 6:16 pm
Forum: Computer Chess Club: Programming and Technical Discussions
Topic: How could a compiler break the lockless hashing method?
Replies: 312
Views: 33756

Re: How could a compiler break the lockless hashing method?

I think you are confusing an unknown/undefined value with undefined behaviour. The latter is a technical term with a specific, well-defined, meaning. Reading a volatile variable isn't UB. Well, it was said somewhere that race conditions are mentioned in the standard as a form of undefined behavior,...