Auburn / FastNoiseLite

Fast Portable Noise Library - C# C++ C Java HLSL GLSL JavaScript Rust Go
http://auburn.github.io/FastNoiseLite/
MIT License
2.79k stars 327 forks source link

Compilation warning #35

Closed 1Hyena closed 4 years ago

1Hyena commented 4 years ago

src/src/gen-noise.cpp||In function ‘FN_DECIMAL FastAbs(FN_DECIMAL)’:| src/src/gen-noise.cpp|187|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘double’ may alter its value [-Wfloat-conversion]| src/src/gen-noise.cpp||In member function ‘void FastNoise::SetSeed(int)’:| src/src/gen-noise.cpp|204|warning: conversion to ‘unsigned char’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|212|warning: conversion to ‘unsigned char’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp||In function ‘FN_DECIMAL ValCoord2D(int, int, int)’:| src/src/gen-noise.cpp|281|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp||In function ‘FN_DECIMAL ValCoord3D(int, int, int, int)’:| src/src/gen-noise.cpp|290|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp||In function ‘FN_DECIMAL ValCoord4D(int, int, int, int, int)’:| src/src/gen-noise.cpp|300|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp||In member function ‘FN_DECIMAL FastNoise::GradCoord4D(unsigned char, int, int, int, int, FN_DECIMAL, FN_DECIMAL, FN_DECIMAL, FN_DECIMAL) const’:| src/src/gen-noise.cpp|326|warning: conversion to ‘unsigned char’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp||In member function ‘FN_DECIMAL FastNoise::SingleSimplex(unsigned char, FN_DECIMAL, FN_DECIMAL, FN_DECIMAL) const’:| src/src/gen-noise.cpp|1083|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1084|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1085|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1086|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1126|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1127|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1128|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1129|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1130|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1131|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp||In member function ‘FN_DECIMAL FastNoise::SingleSimplex(unsigned char, FN_DECIMAL, FN_DECIMAL) const’:| src/src/gen-noise.cpp|1281|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1282|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1283|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1337|warning: conversion to ‘FN_DECIMAL {aka float}’ alters ‘double’ constant value [-Wfloat-conversion]| src/src/gen-noise.cpp|1338|warning: conversion to ‘FN_DECIMAL {aka float}’ alters ‘double’ constant value [-Wfloat-conversion]| src/src/gen-noise.cpp||In member function ‘FN_DECIMAL FastNoise::SingleSimplex(unsigned char, FN_DECIMAL, FN_DECIMAL, FN_DECIMAL, FN_DECIMAL) const’:| src/src/gen-noise.cpp|1348|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1349|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1350|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1351|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1352|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1385|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1386|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1387|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1388|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1389|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1390|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1391|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1392|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1393|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1394|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1395|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1396|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp||In member function ‘FN_DECIMAL FastNoise::SingleCellular(FN_DECIMAL, FN_DECIMAL, FN_DECIMAL) const’:| src/src/gen-noise.cpp|1712|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1713|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1714|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1738|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1739|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1740|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1764|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1765|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1766|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1795|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1795|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1795|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp||In member function ‘FN_DECIMAL FastNoise::SingleCellular2Edge(FN_DECIMAL, FN_DECIMAL, FN_DECIMAL) const’:| src/src/gen-noise.cpp|1823|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1824|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1825|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1830|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘double’ may alter its value [-Wfloat-conversion]| src/src/gen-noise.cpp|1831|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘double’ may alter its value [-Wfloat-conversion]| src/src/gen-noise.cpp|1845|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1846|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1847|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1852|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘double’ may alter its value [-Wfloat-conversion]| src/src/gen-noise.cpp|1853|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘double’ may alter its value [-Wfloat-conversion]| src/src/gen-noise.cpp|1867|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1868|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1869|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1874|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘double’ may alter its value [-Wfloat-conversion]| src/src/gen-noise.cpp|1875|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘double’ may alter its value [-Wfloat-conversion]| src/src/gen-noise.cpp||In member function ‘FN_DECIMAL FastNoise::SingleCellular(FN_DECIMAL, FN_DECIMAL) const’:| src/src/gen-noise.cpp|1935|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1936|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1956|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1957|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1977|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|1978|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|2003|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|2003|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp||In member function ‘FN_DECIMAL FastNoise::SingleCellular2Edge(FN_DECIMAL, FN_DECIMAL) const’:| src/src/gen-noise.cpp|2029|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|2030|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|2035|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘double’ may alter its value [-Wfloat-conversion]| src/src/gen-noise.cpp|2036|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘double’ may alter its value [-Wfloat-conversion]| src/src/gen-noise.cpp|2047|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|2048|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|2053|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘double’ may alter its value [-Wfloat-conversion]| src/src/gen-noise.cpp|2054|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘double’ may alter its value [-Wfloat-conversion]| src/src/gen-noise.cpp|2065|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|2066|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘int’ may alter its value [-Wconversion]| src/src/gen-noise.cpp|2071|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘double’ may alter its value [-Wfloat-conversion]| src/src/gen-noise.cpp|2072|warning: conversion to ‘FN_DECIMAL {aka float}’ from ‘double’ may alter its value [-Wfloat-conversion]| src/src/gen-noise.cpp|186|warning: ‘int FastAbs(int)’ defined but not used [-Wunused-function]|

1Hyena commented 4 years ago

@Auburns no comments? Why invalid?

Auburn commented 4 years ago

You gave no info about the issue, compiler version, compiler settings, are you using doubles/floats?

1Hyena commented 4 years ago

fair enough. I just tested this on another system and got even more warnings, possibly because it has newer gcc version (9.2.0), Arch Linux.

Here's part of the Makefile:

CC      = g++
PROF    = -O3
C_FLAGS = -std=c++14 -Wall -Wextra -pedantic-errors -Wconversion -Wno-unused-parameter -fmax-errors=5 $(PROF)

Getting a lot of stuff like this:

warning: conversion from ‘int’ to ‘unsigned char’ may change value [-Wconversion]

warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
*reinterpret_cast<int*>(&x) ^ (*reinterpret_cast<int*>(&x) >> 16)

In member function ‘FN_DECIMAL FastNoise::GetNoise(FN_DECIMAL, FN_DECIMAL, FN_DECIMAL) const’:
warning: this statement may fall through [-Wimplicit-fallthrough=]
switch (m_fractalType)

In member function ‘FN_DECIMAL FastNoise::GetValue(FN_DECIMAL, FN_DECIMAL, FN_DECIMAL) const’:
warning: ‘zs’ may be used uninitialized in this function [-Wmaybe-uninitialized]
static FN_DECIMAL Lerp(FN_DECIMAL a, FN_DECIMAL b, FN_DECIMAL t) { return a + t * (b - a); }