Re: buildd on Armel, PowerPC and S390(x)? agree on narrowing error, why?
On Fri, Dec 09, 2011 at 10:41:35AM +0100, Steffen Möller wrote:
> Dear list,
>
> I just sponsored a package that built nicely locally with g++ 6.4.2-5 on
> amd64 but fails on the platforms listed in the subject line:
>
> https://buildd.debian.org/status/package.php?p=ball&suite=sid
>
> which gives plenty of repeats of
>
> .. /source/DATATYPE/hashGrid.C:23:3: error: narrowing conversion of '-0x00000000000000001' from 'int' to 'const char' inside { } [-fpermissive]
>
>
> I am starring at it for a while now and googled, and from
> >From http://msdn.microsoft.com/en-us/library/c70dax92.aspx I can understand that
> the regular 1 is taken as an integer constant. So in the code below it should
> instead possibly read {'\0', '\1', (char) -1 } for {0,1,-1} ? I would not like
> that too much. And even if so, all platforms should behave the same.
>
>
> #include <BALL/DATATYPE/hashGrid.h>
>
> namespace BALL
> {
> namespace __private
> {
> const char neighbour_table_[27][3] =
> {
> { 0, 0, 0 }, { 0, 0, -1 }, { 0, 0, 1 },
> { 0, -1, -1 }, { 0, -1, 0 }, { 0, -1, 1 },
> { 0, 1, -1 }, { 0, 1, 0 }, { 0, 1, 1 },
> {-1, 0, -1 }, {-1, 0, 0 }, {-1, 0, 1 },
> {-1, -1, -1 }, {-1, -1, 0 }, {-1, -1, 1 },
> {-1, 1, -1 }, {-1, 1, 0 }, {-1, 1, 1 },
> { 1, 0, -1 }, { 1, 0, 0 }, { 1, 0, 1 },
> { 1, -1, -1 }, { 1, -1, 0 }, { 1, -1, 1 },
> { 1, 1, -1 }, { 1, 1, 0 }, { 1, 1, 1 }
> };
> }
> }
>
> /// file ends here
>
> where the header file reads
>
> namespace BALL
> {
> namespace __private
> {
> extern const char BALL_EXPORT neighbour_table_[27][3];
> }
>
> ....
>
> }
>
>
> Gcc 4.6.2-5 on amd64 does not complain at all. I do not know the version of gcc on the buildds.
>
> Suggestions?
Replace "char" with "signed char".
Char defaults to unsigned on some architectures and signed on others.
Mike
Reply to: