Skip to content

Commit 6facf69

Browse files
authored
[flang][runtime] Correct RANDOM_INIT seed generation (#106250)
The initial seed was generated from a bitwise AND ("&") of two clock-generated values, instead of an XOR or (best) a truncated integer multiplication. Maybe I mistyped a shift-7 instead of a shift-6 or shift-8 when I wrote that line, but it was most likely just stupidity. Fixes #106221.
1 parent 4228e28 commit 6facf69

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

flang/runtime/random.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void RTNAME(RandomInit)(bool repeatable, bool /*image_distinct*/) {
4242
#ifdef CLOCK_REALTIME
4343
timespec ts;
4444
clock_gettime(CLOCK_REALTIME, &ts);
45-
generator.seed(ts.tv_sec & ts.tv_nsec);
45+
generator.seed(ts.tv_sec ^ ts.tv_nsec);
4646
#else
4747
generator.seed(time(nullptr));
4848
#endif

0 commit comments

Comments
 (0)