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]

Is it a Bug? (void*)


Hi

I'm porting lots of stuff to windows (i know, *arg*...) and while doing
so i found something interesting in a C Source file:

 void* myptr = (void*)otherptr + 1;

Which doesn't compile with the microsoft compiler (error: void*: unknown
size). Now i think, that microsoft is right in that case, and that void
really has an unknown size.

Since the "+ 1" should add something like "one times sizeof type" to the
pointer, what should the compiler add when void is encountered? I think
the above is wrong and dangerous. Should the compiler catch this? With
C++ gcc prints an error and exits, but because of type conversions, not
because of the addition.

I attached a small test program, which demonstrates this (maybe bug...
;o)).

Should i officially report this issue?

Cheers, Markus

Attachment: test.c
Description: test.c


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