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: [C++ PATCH] Battle of the comptypes (PR c++/35049)


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.
>


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