Is it a Bug? (void*)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux