This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

I miss a gcc warning


Hi all,

Porting an application to x86_64 I found a line, where I assign an
uintptr_t to an unsigned int an I wondered why I didnt get any
warning.
I definitely  remember that I got warnings in such cases before so I
tried to add some stupid lines to the code to get the warning, but I
couldn't make the code bad enough.

Is it a gcc-issue? or I forget to add some -Wxxx switches? Or gcc
should't wanr me in case of uintptr_t to <some small> cast?

My gcc is based on gcc-4.1.2 but I have no more informaton about it.

My flags are these:
 -gdwarf-2
 -O1
 -nostdinc
 -nostdinc++
 -Wcomment
 -Wformat
 -Wimplicit
 -Wreturn-type
 -Wswitch
 -W
 -Wpointer-arith
 -Wcast-qual
 -Wwrite-strings
 -Wstrict-prototypes
 -Woverloaded-virtual
 -Wuninitialized
 -c


My original code was like this:

extern uintptr_t externfn();

struct data {
   unsigned int member;
}data;

int fn()
{
  data.member = externfn(); // I dont get any warning, this is my problem
  return (int) data;  // I got warning here
}



Later I tried to modify the fn() to get the warning, so now it looks like this:
int fn()
{
  char c;
  uintptr_t p = malloc(1);     // I get a warning because of implicit
void* to integer cast
  c = p;
      // NO WARNING;
 return c;                             // to use c
}


Thanks in advance,
Tibor


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]