Skip to content

Incorrect mersenne_twister_engine equality comparison on initial seed states #37817

@hubert-reinterpretcast

Description

@hubert-reinterpretcast
Bugzilla Link 38469
Version 7.0
OS All
Attachments Program as described in the Description
CC @mclow

Extended Description

[rand.req.eng] specifies the comparison between two engines as returning true
if the infinite sequences of values that would be generated by repeated calls
to their respective operator()s are equivalent.

The attached program seeds two mersenne_twister_engines with specific states. It asserts that the values returned by the engines match for some number of calls, and that the engines are considered equivalent after that set of calls.

It then asserts that the engines were equivalent before those calls.
The assertion fails; however, either an earlier assertion should have failed, or the engines before those calls do indeed produce equivalent infinite sequences of values.

Online compiler: https://wandbox.org/permlink/a3frEvZRLgezujN1

=== COMPILER INVOCATION:
clang++ -stdlib=libc++ -std=c++17 -pedantic-errors -Wall -Wextra -Werror -xc++ mteEqSeededStates.cc -o ./a.out

=== RUN SCRIPT:
./a.out

=== EXPECTED RUN OUTPUT:
(Exits with rc=0).

=== ACTUAL RUN OUTPUT:
a.out: mteEqSeededStates.cc:74: int main(): Assertion `enginesCompareEqualOnInit' failed.

=== COMPILER VERSION INFO (clang++ -v):
clang version 8.0.0 (https://github.com/llvm-mirror/clang.git 074cccc152df061007c8500515698b57a5af7103) (https://github.com/llvm-mirror/llvm.git 40868d4)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/wandbox/clang-head/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.0.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Candidate multilib: .;@m64
Selected multilib: .;@m64

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillalibc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.random

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions