https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95676

--- Comment #2 from James McCoy <jamessan at jamessan dot com> ---
Apologies for leaving off the build/configure information.  I shouldn't have
assumed one would have access to Debian's compiler.

--8<--
abel% g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/9/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Debian 9.3.0-13'
--with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs
--enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,gm2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-9
--program-prefix=arm-linux-gnueabihf- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm
--disable-libquadmath --disable-libquadmath-support --enable-plugin
--enable-default-pie --with-system-zlib --with-target-system-zlib=auto
--enable-objc-gc=auto --enable-multiarch --disable-sjlj-exceptions
--with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb
--disable-werror --enable-checking=release --build=arm-linux-gnueabihf
--host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
--with-build-config=bootstrap-lto-lean --enable-link-mutex
Thread model: posix
gcc version 9.3.0 (Debian 9.3.0-13) 
-->8--

The original issue was this test code (which uses googletest) from msgpack-c
unexpectedly failing with compiled with "g++ -std=c++11 -O1" but working with
"g++ -std=c++11 -O0":

--8<--
TEST(object_with_zone, system_clock_impl_min)
{
    std::chrono::system_clock::time_point
v(std::chrono::system_clock::time_point::min());
    msgpack::zone z;
    msgpack::object obj(v, z);
    EXPECT_TRUE(obj.as<std::chrono::system_clock::time_point>() == v);
}
-->8--

The test is verifying that the min value can round-trip through msgpack::object

Changing EXPECT_TRUE(... == v) to EXPECT_EQ(..., v) makes the code work with
-O1, as does storing obj.as<...>() into a temporary (e.g., v2) and using that
in the EXPECT_TRUE(v2 == v).

Removing googletest from the picture was successful, so the example could be
reduced to:

--8<--
#include <msgpack.hpp>

bool check_equality()
{
    std::chrono::system_clock::time_point
v(std::chrono::system_clock::time_point::min());
    msgpack::zone z;
    msgpack::object obj(v, z);
    return obj.as<std::chrono::system_clock::time_point>() == v;
}

int main()
{
    return check_equality();
}
-->8--


This is what I then had creduce work with.  The test script simply compiled the
file twice, once with "g++ -std=c++11 -O0" and once with "g++ -std=c++11 -O1",
verifying that the resulting binaries had an exit code of non-zero and zero,
respectively.

The bug reporting guidelines state to provide minimized test cases, so that's
what I did.  If there's more information, I'm happy to provide it.  I'm not a
compiler developer, so I'm not sure what information is needed.

Reply via email to