MersenneTwister-Lab / TinyMT

Tiny Mersenne Twister
Other
210 stars 37 forks source link

Warnings: sign-conversion #4

Closed ax3l closed 4 years ago

ax3l commented 6 years ago

With modern compilers, the lines -((int32_t)(t1 & 1)) & random->tmat in tinymt32.h/c throw warnings of the form

-((int32_t)(t1 & 1)) & random->tmat
^----------------------------------
warning: conversion to ‘uint32_t {aka unsigned int}’ from ‘int’ may change the sign of the result [-Wsign-conversion]

when compiled with -Wsign-conversion.

The same warning is probably also present in tinmy64.h/c.

Maybe an intermediate const variable and an explicit cast can solve this.

Used in: https://github.com/alpaka-group/alpaka/pull/579 Diff: https://github.com/alpaka-group/alpaka/commit/783b8f7013b1961a903fc52e4ed56ed7c743b6a6