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

Re: [PATCH, PR 45934] Devirtualization aware of dynamic type changes


On Tue, Nov 23, 2010 at 8:44 PM, Jay K <jay.krell@cornell.edu> wrote:

>> oh yeah, people counting on overflow are setting up themselves
>> to be surprised -- and that has happened.
>
>
>
> I know. I thought I alluded to my awareness -- I thought it required
> certain switches. Perhaps I was confusing it with switches to
> turn it off or to get the warnings. I did run -Wstrict-overflow=4 or such
> on some code and fixed it to use unsigned to fix the warnings.

yes; note however that the warning is only there as a courtesy, to help
you clean up the code.  And although setting
the warning switch lets the compiler tell what it thinks of certain
operations, that does not prevent it from operating under the standard
semantic that signed integer overflow invokes undefined behaviour.

> Stuff about distributing minus across division.
> Still, it's a somewhat dangerous change to give existing code non-silent overflow.

what is dangerous is that it was written in the first place :-)

> (or rather, I realize runtime overflow remains predominantly silent,
> but the compiler is taking advantage of the fact that it might be not silent, and
> so on; my wording is poor here, but I do understand...)
>
>
>
> I've also written code to check for overflow, and it depended on silent overflow.
> Sometimes there is a bit of an arms race between the compiler and the programmer.

well, I've come to the belief that programmers should write simple
codes -- that is the only
place where they can expect to outsmart compilers :-)

[...]
> You know, typically compilers warn only in the context of the current
> target, not in the context of the more abstract standard.

I suspect that is a function of the `set of compilers' you consider.

> (Gcc's warning about long strings is a notable counterpoint.)
>
>
> Heck, a crazier extreme would be that gcc could warn about code
> known to miscompile with older gcc. A sort of "portability warning".

That is not unheard of -- think -fabi-version.  But, one has to keep
things in perspective and realize that there is a balance to have.
I'm not really interested in knowing that GCC-2.6.2 was miscompiling
templates and multiple inheritance.  That was a long time ago -- more than
15 year ago.

> Would be very costly to implement. And little used.

therefore practically pointless.

[...]

> "Hey, interesting point about constructors/destructors changing
> vtable pointer (or abstract type). What about memcpy?"

my advice: it is not meant for OOP :-)


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