This is the mail archive of the gcc-bugs@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]

[Bug c++/45265] GCC has an intermittent bug when computing the address of function parameters



------- Comment #27 from matz at gcc dot gnu dot org  2010-08-12 18:05 -------
Oh, this fun.  Enjoyable, really! ;-)

So, you admit that MSVC does in fact "miscompile" your perfectly fine cdecl
code, if you request optimization from it?  How bad is that of them?
Terrible!  I would consider creating a bug report with them, because if they
miscompile your code with optimizations it must surely be their bug.  After
all optimization is a process of transforming a valid program into another
program that behaves exactly the same, hence if they optimize your valid
program into a crasher, what else could it be than a bug in their compiler?

I mean, really.  They are supposed to provide a commercial grade compiler.
How can it be that they force you to deactivate optimization options
(and hence live with slow runtime) just so that your valid cdecl program
doesn't crash?

One side remark about your p2-p1 claim:
> char* p1=random_address();
> char* p2=another_random_address();
> 
> Any compiler that does not predictably compute p2-p1 is a piece of crap. You
> can twist C99 all you want, but whenever p2-p1 is left to some undefined
> criteria of the compiler then it is just an absolute piece of crap. Period.

You obviously never used segmented platforms (old DOS was such a thing,
but there are others more recent, e.g. Cell with PowerPC is similar in this
respect).  On those it was valid only to sunstract pointers from each other
when they pointed into the same segment.  Because the pointer difference type
was a 16 bit type, whereas the pointers could address 1MB of memory (hence 
effectively 20 bit).  If you do the math you'll see that it's impossible
to map all 2^20 possible differences between pointers (unsigned 2-completement
20-bit arithmetic, otherwise 2^21 differences) into just 16 bit.  So yes,
on those platforms it really was impossible to substract two arbitrary
pointers.

C (the language) reflects such constraints.

With complete trust in your incapability to grok these concepts. but hats
off to a capable troll,
Michael.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45265


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