[llvm-bugs] [Bug 34206] New: Linear congruential generator produces other values than gcc and msvc

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 16 02:10:50 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=34206

            Bug ID: 34206
           Summary: Linear congruential generator produces other values
                    than gcc and msvc
           Product: libc++
           Version: 5.0
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: dirk.reinbach at gmail.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

Created attachment 18991
  --> https://bugs.llvm.org/attachment.cgi?id=18991&action=edit
linear_congruential_engine test

To my understanding the C++ standard does not mandate the algorithms for random
number distributions but it does mandate the algorithms for random number
generators like linear_congruential_engine. So one should be able to generate
consistent random values across all platforms/compilers.

However, i stumbled upon inconsistent values between various compilers and
verified this observation with online compilers. I am not sure which compiler
is right, but at least gcc and msvc agree on their results.

Please find attached a code snippet to reproduce the observed behavior.

I put this code snippet into Rextester:

  http://rextester.com/l/cpp_online_compiler_gcc (g++ 5.4.0)
  http://rextester.com/l/cpp_online_compiler_clang (clang 3.8.0)
  http://rextester.com/l/cpp_online_compiler_visual (Microsoft 19.00.23506 for
x86)

Output:

  25214903928 206026503483683 245470556921330 (gcc)
  25214903928 18444698300399350051 8295313034219953650 (clang)
  25214903928 206026503483683 245470556921330 (msvc)

I also put this code snippet into a Compiler Explorer project. It illustrates
that Clang 3.8 and Clang trunk produce exactly the same code/values.

  https://godbolt.org/g/rBSjaS

A possibly somehow related issue:

  https://bugs.llvm.org/show_bug.cgi?id=27839

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170816/68634eaa/attachment.html>


More information about the llvm-bugs mailing list