]> git.sesse.net Git - stockfish/commitdiff
Fix involuntary conversions of ExtMove to Move
authorMarco Costalba <mcostalba@gmail.com>
Sun, 13 Aug 2017 18:01:26 +0000 (11:01 -0700)
committerMarco Costalba <mcostalba@gmail.com>
Thu, 17 Aug 2017 09:04:00 +0000 (02:04 -0700)
The trick is to create an ambiguity for the
compiler in case an unwanted conversion to
Move is attempted like in:

    ExtMove m1{Move(17),4}, m2{Move(4),17};

    std::cout << (m1 < m2) << std::endl; // 1
    std::cout << (m1 > m2) << std::endl; // 1(!)

This fixes issue #1204

No functional change.

src/movegen.h

index 8ae80118783c626dba484598282f5abb2653e99a..825605704c920ebd52220ae4b63ec9b35ecf66a3 100644 (file)
@@ -42,6 +42,10 @@ struct ExtMove {
 
   operator Move() const { return move; }
   void operator=(Move m) { move = m; }
+
+  // Inhibit unwanted implicit conversions to Move
+  // with an ambiguity that yields to a compile error.
+  operator float() const;
 };
 
 inline bool operator<(const ExtMove& f, const ExtMove& s) {