public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Mark Mitchell <mark@codesourcery.com>
To: Joe Buck <jbuck@synopsys.COM>
Cc: Lubos Lunak <l.lunak@sh.cvut.cz>,
	"kde-core-devel@mail.kde.org" <kde-core-devel@mail.kde.org>,
	Franz Sirl <Franz.Sirl-kernel@lauterbach.com>,
	"gcc@gcc.gnu.org" <gcc@gcc.gnu.org>
Subject: Re: KDE hackers, please read (was [nathan@codesourcery.com: Re: GCC
Date: Mon, 10 Dec 2001 11:39:00 -0000	[thread overview]
Message-ID: <47830000.1008012745@gandalf.codesourcery.com> (raw)
In-Reply-To: <200112101914.LAA17216@atrus.synopsys.com>



--On Monday, December 10, 2001 11:14:30 AM -0800 Joe Buck 
<jbuck@synopsys.COM> wrote:

>>
>> >    3) Persuade gcc folks to add compiler switch that makes gcc use
>> >    string comparing when doing rtti, and simply compile whole KDE with
>> > this switch turned on.
>
> Mark writes:
>> All code in the application -- including the C++ run-time library --
>> needs to be compiled the same way, so you would have to rebuild
>> everything to do this.
>
> In this case, that isn't clear to me.  All code needs to be compiled the
> same way if the flag in question produces an incompatible ABI, but I'm
> not sure it would necessarily be true in this case.

This is exactly the kind of thing we shouldn't tell people. :-)

It is true that if you use strcmp with class data structures that
expect address comparison, you are safe.  The other direction is not
safe.  So, if there is ever a use of RTTI or exception-handling in
the code that was compiled without the special switch, but applying
to classes from the code compiled with the special switch, you have
problems.

>> Mixing C++ and dlopen w/o RTLD_GLOBAL is fundamentally wrong.
>
> This goes too far.

Well, perhaps.  See below.

> What's broken in the KDE case is that two contradictory things are being
> requested: RTTI assuming a global type system, and dynamic loading
> assuming private type systems.

That's the *specific* thing that's going wrong this time.  There are
lots of other things that might go wrong, and even enumerating them
is difficult.  Nathan already mentioned the fact that the same
template instantiation may have multiple addresses.  That applies
to static data members, not just functions; this is a potentially
catastrophic problem.

(The compiler is also allowed to depend on function address comparisions 
when optimizing, even if the code does not do so explicitly:

  int id(int i) { return i; }

  void f(int (*fp)(int), int i) {
    return fp(i);
  }

could be transformed into:

  void f(int (*fp)(int), int i) {
    if (fp == &id) return i;
    else return fp(i);
  }

We don't currently ever do this, but we could.)

There are other objects with vague linkage besides RTTI data, such as
static data in inline functions with external linkage.

Remember that your code need not have these constructs; all that is
necessary is that you #include something that does, including something
from the standard library.

Yes, if you really, really know what you are doing and you are willing
to write code that is unportable, or that does not make use of many
language features, and you know the ABI, you may be able to get away
with this.

You are, however, playing with fire.

I certainly do not think that G++ should be obliged to make any
guarantees about this situation.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

  reply	other threads:[~2001-12-10 19:39 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Pine.LNX.4.42.0112041339390.30216-110000@bochum.stuttgart.redhat.com>
2001-12-04 13:21 ` KDE hackers, please read (was [nathan@codesourcery.com: Re: GCC 3.0.3: Bugs to Fix]) (fwd) Waldo Bastian
2001-12-04 13:29   ` shaheed
2001-12-04 14:51   ` Joe Buck
2001-12-04 16:37     ` Dirk Mueller
2001-12-05 12:16       ` Mark Mitchell
2001-12-09 23:58     ` Waldo Bastian
2001-12-10  0:52       ` Simon Hausmann
2001-12-10  2:45         ` Lubos Lunak
2001-12-10  9:55           ` Mark Mitchell
2001-12-10 11:16             ` KDE hackers, please read (was [nathan@codesourcery.com: Re: GCC Joe Buck
2001-12-10 11:39               ` Mark Mitchell [this message]
2001-12-10 11:47                 ` Joe Buck
2001-12-11 13:00             ` KDE hackers, please read (was [nathan@codesourcery.com: Re: GCC 3.0.3: Bugs to Fix]) (fwd) Alexandre Oliva
2001-12-11  9:28               ` Mark Mitchell
2001-12-10  1:33       ` Richard Henderson
2001-12-10  2:41         ` Andreas Schwab
2001-12-10  2:07       ` Nathan Sidwell
2001-12-10  3:01       ` Jakub Jelinek
2001-12-05  1:23   ` Nathan Sidwell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47830000.1008012745@gandalf.codesourcery.com \
    --to=mark@codesourcery.com \
    --cc=Franz.Sirl-kernel@lauterbach.com \
    --cc=gcc@gcc.gnu.org \
    --cc=jbuck@synopsys.COM \
    --cc=kde-core-devel@mail.kde.org \
    --cc=l.lunak@sh.cvut.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).