public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Doug Gregor" <doug.gregor@gmail.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: "GCC Patches" <gcc-patches@gcc.gnu.org>
Subject: Re: [C++ PATCH] Battle of the comptypes (PR c++/35049)
Date: Wed, 06 Feb 2008 15:59:00 -0000	[thread overview]
Message-ID: <24b520d20802060759o692c91cck204f86f221050b59@mail.gmail.com> (raw)
In-Reply-To: <6dc9ffc80802060750m7b9f36fcgc768663db366667c@mail.gmail.com>

Once I get the O.K. from a C++ front end maintainer to commit this,
yes; I'll include that new test case.

  - Doug

On Feb 6, 2008 10:50 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> Hi Doug,
>
> Can you include a testcase from
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35096
>
>
> H.J.
>
> On Feb 5, 2008 9:52 AM, Doug Gregor <doug.gregor@gmail.com> wrote:
> > PR c++/35049 is a 4.3 regression where we are failing to emit an error
> > when performing addition of vector types that don't have the same base
> > type. The bug seems to have been triggered by a recent change in the
> > canonical types system, but in fact it's been a ticking time bomb for
> > a while. The bug shows up on i386-apple-darwin9.1.0 and (for some
> > people) on i686-pc-linux-gnu
> >
> > The C front end declares the function comptypes like this, in c-tree.h:
> >
> >   extern int comptypes(tree, tree);
> >
> > Parts of the C front end and the C/C++ commit bits use this comptypes.
> > However, this comptypes actually resides in c-typeck.c, which is not
> > linked into the C++ compiler.
> >
> > The C++ front end declares comptypes like this, in cp-tree.h:
> >
> >   extern int comptypes(tree, tree, int);
> >
> > That int is the "strict" parameter, that tells the routine how to
> > compare the types, e.g., strict comparison, checking for base and
> > derived, derived and base, or redeclarations.
> >
> > The fun comes in where the C/C++ common bits call comptypes with 2
> > arguments (as they should), but that ends up calling the C++
> > comptypes... with random data for the "strict" argument. So sometimes
> > we'll get strict comparisons (if that parameter is zero), sometimes
> > we'll get comparisons based on derived/base matching, etc. Most likely
> > this didn't matter before because the C bits don't deal with such C++
> > types often, but in the case of this bug we're thwarting the canonical
> > type system (which is only enabled with strict==COMPARE_STRICT) and
> > getting the wrong answer from comptypes.
> >
> > This patch just renames "comptypes" in the C++ front end to
> > "cp_comptypes", and adds a 2-argument "comptypes" function to the C++
> > front end that accepts calls from the C/C++ common bits and forwards
> > on to cp_comptypes.
> >
> > Tested i386-apple-darwin9.1.0; okay for mainline?
> >
> >   - Doug
> >
> > 2008-02-05  Douglas Gregor  <doug.gregor@gmail.com>
> >
> >         PR c++/35049
> >         * typeck.c (structural_comptypes): Call cp_comptypes.
> >         (comptypes): New; called from the C/C++ common bits to perform
> >         strict checks.
> >         (cp_comptypes): Renamed from comptypes, which is already used,
> >         with a different signature, by the C++ front end.
> >         (build_reinterpret_cast_1): Call cp_comptypes.
> >         (ptr_reasonably_similar): Ditto.
> >         * decl.c (decls_match): Ditto.
> >         * cvt.c (convert_to_reference): Ditto.
> >         * cp-tree.h (same_type_p): Ditto.
> >         (same_or_base_type_p): Ditto.
> >         (comptypes): Rename to cp_comptypes.
> >         * pt.c (canonical_type_parameter): Call cp_comptypes.
> >
>

  reply	other threads:[~2008-02-06 15:59 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-05 17:53 Doug Gregor
2008-02-06 15:51 ` H.J. Lu
2008-02-06 15:59   ` Doug Gregor [this message]
2008-02-06 16:48     ` H.J. Lu
2008-02-06 22:51 ` Andreas Tobler
2008-02-06 22:55   ` Manuel López-Ibáñez
2008-02-06 23:16     ` Andrew Pinski
2008-02-07  8:59 ` Paolo Bonzini
2008-02-07 13:46   ` [C/C++/ObjC/ObjC++ " Paolo Bonzini
2008-02-07 13:52     ` H.J. Lu
2008-02-07 14:59       ` Paolo Bonzini
2008-02-07 15:05         ` H.J. Lu
2008-02-07 15:07           ` Jakub Jelinek
2008-02-07 15:47             ` Richard Guenther
2008-02-07 15:57               ` Doug Gregor
2008-02-07 16:22                 ` Paolo Bonzini
2008-02-07 15:07           ` Doug Gregor
2008-02-11  4:58     ` Mark Mitchell
2008-02-11 12:23       ` Joseph S. Myers
2008-02-11 13:33         ` Paolo Bonzini
2008-02-07 20:49   ` [C++ " Joseph S. Myers
2008-02-08 10:42     ` Paolo Bonzini
2008-02-08 15:49       ` Joseph S. Myers
2008-02-08 15:59         ` Doug Gregor
2008-02-08 16:37           ` Paolo Bonzini
2008-02-08 20:02           ` Joseph S. Myers
2008-02-07 18:54 ` Andreas Krebbel
2008-02-07 19:06   ` Doug Gregor

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=24b520d20802060759o692c91cck204f86f221050b59@mail.gmail.com \
    --to=doug.gregor@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hjl.tools@gmail.com \
    /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).