Hi
champagne,
I had the same problem as
emerentius_, using "-O2".
I discovered that somehow the 'zhou_i' initialization that's done in ZH_GLOBAL::ZH_GLOBAL(),
either wasn't working, or the result was somehow being trashed.
[ 'zhou_i.cells_unsolved' was set to zero at the top of main(), but all other fields were as they should be. ]
It doesn't happen without "-O2".
Adding this line at the top of main(), "fixes" the problem:
"new (&zh_g) ZH_GLOBAL();"
Still no idea why it happens.
I have two other problems, though ...
1) First problem:
For some lists of puzzles, the code gives the proper answers, and for others it doesn't.
It doesn't matter whether I use MSVC or GCC ... I get the same results.
It works fine for the (known) 17's, and for Serg's benchmark puzzles.
One list (for pattern game #340), has with puzzles with 0, 1 and 2+ solutions, and it works fine for those.
For other lists, some multi-solution puzzles are reported as having 0 solutions.
(I haven't seen a problem with a 1-solution puzzle yet, but maybe I haven't done enough testing
Added: an old list of yours, with 24411 puzzles containing exocets, tests just fine).
Here's a short list of "problem" puzzles.
- Code: Select all
12..........79...27..23.5..21...7...67..29...9...6..573916.2...5679....3..25.3.6.
12....78.45.7.81..78..13...275834..1.31.7.4.88.4..137.3425...17..71...5..183.7...
...4.76894.6.8.327789.6..4...8...4.6.67.4.8.2...6.87.....89.27487.......3.......8
1..45.....5.1....3....6...1...51..4..75..9.1...1......597...16.61..75.9....6917..
123...6.9..61.92377.92631.52.5....9.6.19...52...5327163.2.9..6..6..2.97...7..152.
1.3...689..6189.7.7.9.6.....68.....1..15..9.7.97.31...67..........7.....91....7.5
.....6.8.4.6....9.7.9..2.6......49.6.14..7.........4.1.4789.612.6.24......2....4.
...45.....5....7....926....2.4..1.........49..7...4..........64.4...9...6...45.12
129.5.7...5.78.1.278.2.15..2.51...7.8.752.......86725..72.15..65916.8.27..8.72.15
.2...6......7..13...3...5..2.5....6.3.7..2...8.1..................53.....7.1..8..
1.6...........9...7....25.....94.1.6.6.....9.9..76...........67..2..5....9.....54
12...76..4.6...27.7.92...1.2.174.........81........8...1.......86...1...9...7..21
1.345.....5....3.7.8....5.1..5.3..1...4.7..53.31..5..6.67..18...1........4.5..13.
1....67.94567.9.2.7.9....6.2.....47.6......5..97.61....1....29..6..9..1.97.....4.
1.34576...2.1....77.......127463.1..6.571...3.31....76.67..1....1..2.76....57631.
...75.6..4.6....3.7.9.........6..5..6.......19.7..3.6..7..1..4..9...4.7..64......
..34567.9.56..9...8.9..3.....5..7.6......4....3....4..3.4....575.8...39497.345...
.2..5678..56.8.....8....6.5....6859.56..9782.9.85...6....6.59.869.8...5.845....76
...4.3..94.6.89..2..92....4......9.7...972846947....23..2...76....32.49...4..623.
1.....7.....7892.17..1.2.....891..7.......6..5.....1.26....5.9.8......17...8.1.26
1..45....4.....1.....1325.4.9.8.3.1..48....25.......48...9..8..8.4.....19.2...45.
..34.....456...1.3..91....4..8..5.3....8.....9...4...8.9....81..6..9835.8........
.23....8.....8..26789.3....2.8347....6....8.....6.84.....8.3.47........884..6....
19..5.....5.....3....13.546..7...9.3...9714.5...3.4...6....3..4....9..7..........
13..5....45....132....1.54.........551.......9.43.5....95.2......158.29..42.3..5.
.23...7.....7...3.78923.5.6.6..95..3....73....3.....5.3....7..2...3........5..368
.....6..94.6..9...789....64.9.17.4...3.9......6......1.4...761..1...3....7....84.
...4...8.4..5.9...7...3...4..894.....4.....9....3684.55....4.....4.....3.....3647
...456789456789..2789.2.5462.......4..4....27.......58.9...846.......895......27.
.2....4.9....89..2.89132...2..9......48....9..9......13..26.94.8.4.9.32.9.2......
.2......9....8.2...89312........468.3.8......9.4..........6..4..4.......8..14...3
...4....9456......789.......7.....5.....9..7...4....1...1...8..8.7165........7..1
124...789....891.2.....2...2.....9....89...2.6...2.4....2.9.8.....24.69...7...21.
You should probably test those with your MSVC-compiled code.
I use MSVS 2012 ... and I trust it ... but you have "inttypes.h", so you must be using 2013 or later.
[ The only change I needed, was to use "stdint.h" insted of "inttypes.h" ... "#if (_MSC_VER <= 1700) ... #else ..." ]
2) Second problem:
For one list of puzles (17 clues, multiple solutions) ... the GCC-compiled code crashes on some puzzles.
It only happens for GCC-compiled code, and it doesn't matter whether it's "-O2" or "-O0".
[ The MSVC-compiled code, doesn't crash, it just gives "0 solutions" for some of the puzzles ...
9 of 10000 99 of 10000 ]
Added: My mistake on the count.
Also, see next post: crash problem solved !
These are a few of those puzzles that caused (GCC) crashes:
[
There are many more ... in particular, more than the 9 where the MSVC code reported 0-solutions. ]
- Code: Select all
81..3.9........2....4..2......7..8.......4.615..................7.81....9........
...86..........9..4...5.....8......1..2...4..5...1...7....7......1....6.......3.5
...8..5......4............23...9.6..1....7..........9...85.......1....6..4..2.3..
.7..9.3.....8....96..........5..6......4.....34...17.......21..........8...3.....
.7.5.......3.6........1.4.........9...7.2.....4.9...........15...2......8..3....7
....9.....5...72..6....3.7...5....94..7....3...........9..8.......1.......6....2.
For that problem, I was able to catch the crash, by adding lines like these, in (4) places in Zhn_cpp.h
-- places where a structure at "this + 1" is about to be used.
There was one for zh1d[10] slots, and 3 more for "zhou[50]" slots ... assuming I didn't miss anything.
- Code: Select all
if (((this + 1) - zh1d) >= sizeof(zh1d) / sizeof(zh1d[0]))
{
cout << " *** zh1d depth ***" << endl;
exit(0);
}
The one for "zh1d[10]" caught the crashes, oddly enough !
For MSVC code, and GCC code for other puzzle lists, and whether I'm getting incorrect results or not ...
none the code above is ever triggered.
---
P.S.: I saw an error in your non-MS code in "sk_bitfields.h".
It was in a routine that isn't used in this app.
I'm sure you can spot it.
- Code: Select all
inline void SetToBit(const int theBit) {
if (theBit < 64) {
bf.u64[1] = (uint64_t)0;
bf.u64[0]=(uint64_t) 1<< theBit;
}
else {
bf.u64[0] = (uint64_t)1;
bf.u64[1] = (uint64_t)1 << (theBit-64);
}
}