>From the thread on the dar support mailing list: https://sourceforge.net/p/dar/mailman/message/37890758/
On Sat, Sep 02 2023, Thomas wrote: > On Wed, Aug 30, 2023 at 03:24:12PM -0500, John Goerzen wrote: >> On Wed, Aug 30 2023, Denis Corbin wrote: >> >> >> Summary >> >> ======= >> >> g++ 10 works fine with optimization. >> >> g++ 11 or newer work only without optimization. >> >> Hope this helps. >> > >> > Thanks for confirming this is a gcc issue. I don't know what should be the >> > next >> > step, if someone fills a bug report to gcc Debian maintainer? >> >> Well, to be sure, we have a couple of possibilities: >> >> 1) This is a gcc bug, >> >> or 2) There is something in dar (or, for that matter, bzip2 or some >> other library) that is relying on some sort of C/C++ undefined behavior >> (UB) that the optimizer is taking in a different direction. Other >> possibilities could include race conditions, etc. > > To find the root cause why the optimizer does something harmfull in our > case is way over my head. > > But... > I have found a workaround for dar. The appended patch works for me with > dar v2.7.11 and g++ v13.2.0, v12.3.0 and v11.4.0. Means, files generated > with OnFlyIsolation are readable again with default optimizations > activated. > It seems the optimizer does not like the used ternary operator. > > I tested the patch with g++ v10.4.0 and 9.3.0, too without problems but > these versions are working with or without this patch anyway. > > Hope this helps. > > Tom > > [2. text/x-diff; slice_layout.cpp-remove_ternary_operator.patch]...
diff -rupN DAR_a/src/libdar/slice_layout.cpp DAR_b/src/libdar/slice_layout.cpp --- DAR_a/src/libdar/slice_layout.cpp 2023-09-02 09:08:49.657051708 +0200 +++ DAR_b/src/libdar/slice_layout.cpp 2023-09-02 09:11:39.240669572 +0200 @@ -54,7 +54,11 @@ namespace libdar void slice_layout::write(generic_file & f) const { - char tmp = older_sar_than_v8 ? OLDER_THAN_V8 : V8; + char tmp = V8; + if(older_sar_than_v8) + { + tmp = OLDER_THAN_V8; + } first_size.dump(f); other_size.dump(f); first_slice_header.dump(f);