This is an archive of the discontinued LLVM Phabricator instance.

[flang] Fix narrowing warning on macos
ClosedPublic

Authored by tskeith on Apr 12 2021, 9:31 AM.

Details

Summary

With clang 11 on macos we were getting this warning:

flang/runtime/random.cpp:61:30: error: non-constant-expression cannot be narrowed from type 'unsigned long long' to 'runtime::GeneratedWord' (aka 'unsigned int') in initializer list [-Wc++11-narrowing]
          GeneratedWord word{(generator() - generator.min()) & rangeMask};
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
flang/runtime/random.cpp:99:5: note: in instantiation of function template specialization 'runtime::Generate<double, 53>' requested here
    Generate<CppTypeFor<TypeCategory::Real, 8>, 53>(harvest);
    ^

Changing the type of rangeMask fixes it.

Diff Detail

Event Timeline

tskeith created this revision.Apr 12 2021, 9:31 AM
tskeith requested review of this revision.Apr 12 2021, 9:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2021, 9:31 AM
klausler accepted this revision.Apr 12 2021, 9:36 AM
This revision is now accepted and ready to land.Apr 12 2021, 9:36 AM
This revision was landed with ongoing or failed builds.Apr 12 2021, 9:41 AM
This revision was automatically updated to reflect the committed changes.