Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning when compiling my that's use VarHolder #2222

Closed
lgm42 opened this issue Mar 14, 2018 · 2 comments
Closed

Warning when compiling my that's use VarHolder #2222

lgm42 opened this issue Mar 14, 2018 · 2 comments

Comments

@lgm42
Copy link

lgm42 commented Mar 14, 2018

Expected behavior

no warning when building my source

Actual behavior

Each time I build my project I get error :

/home/nicolas/projets/aqit-map/aqit-map-backend/workspace/aqit-map-backend/third party/poco-1.9.0-all/linux/include/Poco/Dynamic/VarHolder.h: In instantiation of ‘void Poco::Dynamic::VarHolder::checkUpperLimit(const F&) const [with F = signed char; T = unsigned int]’:
/home/nicolas/projets/aqit-map/aqit-map-backend/workspace/aqit-map-backend/third party/poco-1.9.0-all/linux/include/Poco/Dynamic/VarHolder.h:370:23: required from ‘void Poco::Dynamic::VarHolder::convertSignedToUnsigned(const F&, T&) const [with F = signed char; T = unsigned int]’
/home/nicolas/projets/aqit-map/aqit-map-backend/workspace/aqit-map-backend/third party/poco-1.9.0-all/linux/include/Poco/Dynamic/VarHolder.h:771:36: required from here
/home/nicolas/projets/aqit-map/aqit-map-backend/workspace/aqit-map-backend/third party/poco-1.9.0-all/linux/include/Poco/Dynamic/VarHolder.h:419:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (from > std::numeric_limits::max())

Steps to reproduce the problem

compile without using [-Wsign-compare

POCO version

1.9.0

Compiler and version

> g++ -v


Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.5' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.5) 

Operating system and version

Linux Ubuntu 16.04

Other relevant information

@mike2307
Copy link

This should fix the issue:

template <typename F, typename T>
void checkUpperLimit(const F& from) const
{
	if ((sizeof(T) < sizeof(F)) &&
		(from > static_cast<F>(std::numeric_limits<T>::max())))
	{
		throw RangeException("Value too large.");
	}
	else
	if ((sizeof(T) == sizeof(F)) &&
		!std::numeric_limits<F>::is_signed &&
		std::numeric_limits<T>::is_signed)
	{
		if (from > static_cast<F>(std::numeric_limits<T>::max()))
		{
			throw RangeException("Value too large.");
		}
	}
}

@aleks-f
Copy link
Member

aleks-f commented Jun 12, 2022

fixed in #2943

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants