On Thu, Dec 14, 2006 at 09:24:24AM +0100, Georg Baum wrote:
> Enrico Forestieri wrote:
>
> > I recently started seeing the following warning while building:
> >
> > ../../../src/support/docstring.C: In member function `wctype_t
> > lyx::ascii_ctype_facet::M_convert_to_wmask(char) const':
> > ../../../src/support/docstring.C:269: warning: overflow in implicit
> > constant conversion
>
> > Georg, do you have any idea? I cannot see anything wrong with line 269
> > in docstring.C and can't figure out what is happening... not to mention
> > that I don't know why I am getting the warning. I am sure that I never
> > saw it before.
>
> What happens is that in this code
>
> wmask_type M_convert_to_wmask(const mask m) const
> {
> wmask_type ret;
> switch (m) {
> case print: ret = wctype("print"); break;
> }
> return ret;
> }
>
> the constant 'print' does not fit into the type of 'm' (which is 'mask').
> From your error message one can see that 'mask' is typedefed to 'char'. On
> my linux box it is 'unsigned short'.
>
> I am pretty sure that qt is to blame here and that it defines a global type
> 'mask', because including qt headers was the only change that happened
> recently. If that is the case you can easily fix the problem by full
> qualification of 'mask':
>
> std::ctype<lyx::char_type>::mask
I investigated the problem and it turned out that qt is innocent here.
Indeed, looking at the preprocessed output I find:
# 38
"/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/i686-pc-cygwin/bits/ctype_base.h"
3
struct ctype_base
{
typedef const int* __to_type;
typedef char mask;
static const mask upper = 01;
static const mask lower = 02;
static const mask alpha = 01 | 02;
static const mask digit = 04;
static const mask xdigit = 0100 | 04;
static const mask space = 010;
static const mask print = 020 | 01 | 02 | 04 | 0200;
static const mask graph = 020 | 01 | 02 | 04;
static const mask cntrl = 040;
static const mask punct = 020;
static const mask alnum = 01 | 02 | 04;
};
The reason I was not seeing the warning before is that I was compiling
using -funsigned-char. Now I was trying to see if that was still
necessary and thus I get the warning. BTW, it seems that -funsigned-char
is no more needed. Indeed, the following test program does the right
thing.
#include <iostream>
static const char print = 0227;
void test_mask(const char m)
{
switch (m) {
case print: std::cout << "print" << std::endl; break;
default: std::cout << "other" << std::endl;
}
}
int main()
{
test_mask(151U);
return 0;
}
--
Enrico