[Libpqxx-general] Error with gcc 4.3, was: pqxx::connection crash under libpqxx 2.6.9 and 3.0.0, OSX Leopard
Kim Bisgaard
kib+pg at dmi.dk
Fri Jul 18 10:52:23 UTC 2008
Jeroen Vermeulen wrote:
> Roger Leigh wrote:
>
>> With 3.0.0 in SVN:
>>
>> g++ -DHAVE_CONFIG_H -I../include -I../include -I/usr/include/postgresql -g -O2 -Werror -Wno-long-double -Wno-div-by-zero -ffor-scope -fstrict-aliasing -Wstrict-aliasing -funit-at-a-time -pedantic -fno-nonansi-builtins -Wall -Wmultichar -W -Wextra -Wfloat-equal -Wundef -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wconversion -Wctor-dtor-privacy -Wendif-labels -Wlogical-op -Woverlength-strings -Wredundant-decls -Wsign-compare -Wwrite-strings -Wnon-virtual-dtor -Wreorder -Wold-style-cast -Woverloaded-virtual -Wsign-promo -Wstrict-null-sentinel -Wformat-security -Winit-self -Wswitch -Wmissing-field-initializers -Wmissing-include-dirs -Wunused -funit-at-a-time -Werror -MT util.lo -MD -MP -MF .deps/util.Tpo -c util.cxx -fPIC -DPIC -o .libs/util.o
>> cc1plus: warnings being treated as errors
>> util.cxx: In function ‘L<unnamed>::absorb_digit(L, R) [with L = short int, R = int]’:
>> util.cxx:122: instantiated from ‘void<unnamed>::from_string_signed(const char*, T&) [with T = short int]’
>> util.cxx:382: instantiated from here
>> util.cxx:105: error: conversion to ‘short int’ from ‘int’ may alter its value
>>
>
> That's in absorb_digit():
>
> template<typename L, typename R>
> inline L absorb_digit(L value, R digit) throw ()
> {
> return 10*value + L(digit);
> }
>
> I'm not too deep into the nitty-gritty of type theory anymore, but I
> suppose this comes from the "10*value".
No it comes from the digit (an int) being shortened down to a "short
int" which of cause can result in a big value being converted into a
negative value. If R where a unsigned char, as it's name suggests, it
would work alright.
Regards,
Kim
More information about the Libpqxx-general
mailing list