Package: libstdc++6
Version: 4.8.0-8
Severity: important

Dear Maintainer,

Attached test case gets the current system time using std::chrono and using
gettimeofday, both with millisecond precision. Using libstdc++6 version 4.8.0-7,
this code works properly, both timestamps being identical. However, since
upgrading to 4.8.0-8, the std::chrono version reports a timestamp in seconds
despite the explicit duration_case to milliseconds, when compiling with GCC 4.6
or 4.7. Using libstdc++6 4.8.0-8 with GCC 4.8 results in correct output.

Looking through the preprocessed output, it seems like there is a a mismatch
between the system_clock duration of the preprocessed output (i.e. the duration
field in the system_clock struct generated by the chrono header) and the one
libstdc++ exposes. The output compiled with GCC 4.7 contains a system_clock
struct with a duration typedef'd to std::chrono::nanoseconds, which results in
correct timestamps using libstdc++6 version 4.8.0-7 but doesn't with version
4.8.0-8 (off by a factor of 1000). GCC 4.8 uses a nanosecond duration as well,
but accesses a system_clock within a V2 namespace, which seems to expose a
nanosecond-precision.

I'm guessing the upgrade to libstdc++6 version 4.8.0-8 changed the system_clock
exposed by the library, now using microsecond precision rather than nanosecond
precision (the V2 system_clock seems to be the one offering nanosecond precision
now). This conflicts with the chrono header, which -- due to the
_GLIBCXX_USE_CLOCK_REALTIME definition -- accesses the system_clock with
nanosecond duration.

Best,
Tim


-- System Information:
Debian Release: jessie/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.8-2-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages libstdc++6 depends on:
ii  gcc-4.8-base       4.8.0-8
ii  libc6              2.17-3
ii  libgcc1            1:4.8.0-8
ii  multiarch-support  2.17-3

libstdc++6 recommends no packages.

libstdc++6 suggests no packages.

-- no debconf information
#include <chrono>
#include <cstdio>
#include <sys/time.h>

int main()
{
    std::chrono::time_point<std::chrono::high_resolution_clock> tp
        = std::chrono::high_resolution_clock::now();
    printf("C++: %lu\n", std::chrono::duration_cast<std::chrono::milliseconds>
        (tp.time_since_epoch()).count());

    struct timeval tv;
    gettimeofday(&tv, NULL);
    printf("C:   %lu\n", tv.tv_sec * 1000 + tv.tv_usec / 1000);

    return 0;
}

Reply via email to