public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mark at codesourcery dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/20103] [4.0/4.1 regression] ICE in create_tmp_var with C99 style struct initializer
Date: Mon, 07 Mar 2005 22:39:00 -0000	[thread overview]
Message-ID: <20050307223914.15195.qmail@sourceware.org> (raw)
In-Reply-To: <20050220111234.20103.falk@debian.org>


------- Additional Comments From mark at codesourcery dot com  2005-03-07 22:39 -------
Subject: Re: [PR c++/20103] failure to gimplify constructors for addressable
 types

Alexandre Oliva wrote:
> On Mar  7, 2005, Mark Mitchell <mark@codesourcery.com> wrote:
> 
> 
>>>>The games that you want to play with type-equality are just too fragile.
>>>
>>>I still don't see why.
> 
> 
>>First, you're using "==".  As I've told you, that's incredibly
>>fragile.
> 
> 
> Not for the purpose I've been trying to describe.

We're at risk of descending into "Yes. No. Yes. No."

I think it's fragile.  Now, reasonable people can disagree about 
software engineering -- it's an art form, not a science -- but my 
opinion is that this is fragile.

I've explained why:

(a) we should never use "==" to compare types, because there's no 
guarantee that the compiler will continue to use "==" types in places 
where it does at present; it might instead switch one of them to be 
same_type_p.  Think about it this way: == has no semantic meaning in 
C++; the only relationship the language knows about is same_type_p.  So, 
using == means that you're doing something with types that doesn't have 
semantics grounded in the language, which doesn't make sense, except in 
places that are trying to get debugging information correct, etc.

(b) you're applying a non-uniform transformation depending on non-local 
knowledge.  What I mean by "non-uniform" is that the assignment to the 
type of the TARGET_EXPR is conditional.  If it were an unconditional 
assignment, I'd be less nervous; then, you'd be asserting that the type 
of the TARGET_EXPR should always be the type of its initializer, which 
might make sense.  What I mean by "non-local" is that your 
transformation only works because of some far-off logic that determins 
how TARGET_EXPRs are created.  It doesn't depend on any documented 
property of TARGET_EXPRs that is enforced throughout the compiler.

Consider the comments you should write for your code:

/* Code in <some function> creates TARGET_EXPRs with "==" types, and 
that must be preserved here.  If you change that code, don't forget to 
update this code!  */

And, then, you should add something to the TARGET_EXPR documentation 
along the lines of:

/* Some TARGET_EXPRs have the same TREE_TYPE as their initializers; some 
don't.  The kinds that do are ...; the kinds that don't are ...  When 
instantiating templates, we preserve equality for types that "==", but 
not necessarily those that are same_type_p.  */

Finally, I've explained that the entire approach is contrary to the way 
we want to do things in templates, which is that you keep a syntactic 
form for dependent expressions until instantiation time, and then run 
through the same exact routines you would have in the parser.  That's 
really the only way we can be sure that the semantics match up.

I'm sorry you're frustruated, but I don't think that your approach is 
the right way to go.

>>But, minor changes elsewhere might make them same_type_p, but not
>>==, in some cases.
>  
> If that's fine for those cases, it will remain so after template
> substitution.  Sounds *exactly* like what I want.

Why would you want that?  If before substitution, the operand had a 
typedef type for the incomplete array, and the TARGET_EXPR had a 
different typedef type for the same incomplete array, wouldn't you want 
to update the type of the TARGET_EXPR?

In the context of a 4.0 patch, I'd be willing to consider a patch like 
yours, using same_type_p instead of "==", and with suitable comments 
explaining what's going on.  For 4.1, we should do better.



-- 


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


  parent reply	other threads:[~2005-03-07 22:39 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-20 17:37 [Bug c++/20103] New: [4.0 regression] ICE in create_tmp_var falk at debian dot org
2005-02-20 17:52 ` [Bug c++/20103] " falk at debian dot org
2005-02-20 19:02 ` pinskia at gcc dot gnu dot org
2005-02-20 19:25 ` pinskia at gcc dot gnu dot org
2005-02-20 19:27 ` pinskia at gcc dot gnu dot org
2005-02-21 21:49 ` pinskia at gcc dot gnu dot org
2005-02-23 11:10 ` [Bug c++/20103] [4.0 regression] ICE in create_tmp_var with C99 style struct initializer pinskia at gcc dot gnu dot org
2005-03-02 13:48 ` [Bug c++/20103] [4.0/4.1 " reichelt at gcc dot gnu dot org
2005-03-03  7:01 ` aoliva at gcc dot gnu dot org
2005-03-03  7:42 ` aoliva at redhat dot com
2005-03-04 23:22 ` aoliva at redhat dot com
2005-03-04 23:30 ` mark at codesourcery dot com
2005-03-05 11:41 ` giovannibajo at libero dot it
2005-03-05 12:16 ` joseph at codesourcery dot com
2005-03-05 13:37 ` aoliva at redhat dot com
2005-03-05 14:03 ` aoliva at redhat dot com
2005-03-05 21:47 ` mark at codesourcery dot com
2005-03-06  7:30 ` aoliva at redhat dot com
2005-03-06 18:02 ` mark at codesourcery dot com
2005-03-07  3:26 ` aoliva at redhat dot com
2005-03-07  4:44 ` mark at codesourcery dot com
2005-03-07  8:51 ` giovannibajo at libero dot it
2005-03-07 14:44 ` aoliva at redhat dot com
2005-03-07 16:05 ` mark at codesourcery dot com
2005-03-07 17:05 ` aoliva at redhat dot com
2005-03-07 18:05 ` mark at codesourcery dot com
2005-03-07 21:58 ` aoliva at redhat dot com
2005-03-07 22:39 ` mark at codesourcery dot com [this message]
2005-03-08  7:25 ` aoliva at redhat dot com
2005-03-08  7:46 ` mark at codesourcery dot com
2005-03-08 20:44 ` aoliva at redhat dot com
2005-03-08 21:55 ` aoliva at redhat dot com
2005-03-11 15:20 ` rth at gcc dot gnu dot org
2005-03-11 19:29 ` aoliva at redhat dot com
2005-03-17 10:42 ` aoliva at redhat dot com
2005-03-17 11:49 ` rth at gcc dot gnu dot org
2005-03-18  5:39 ` aoliva at redhat dot com
2005-03-18 10:16 ` aoliva at redhat dot com
2005-04-02 17:27 ` aoliva at redhat dot com
2005-04-05 14:47 ` pinskia at gcc dot gnu dot org
2005-04-17  3:57 ` mmitchel at gcc dot gnu dot org
2005-04-17  3:59 ` aoliva at redhat dot com
2005-04-17  4:03 ` mark at codesourcery dot com
2005-04-17  6:25 ` aoliva at redhat dot com
2005-07-06 17:03 ` mmitchel at gcc dot gnu dot org
2005-07-22 21:12 ` steven at gcc dot gnu dot org
2005-09-27 16:18 ` mmitchel at gcc dot gnu dot org
     [not found] <bug-20103-2744@http.gcc.gnu.org/bugzilla/>
2005-10-13 20:06 ` pinskia at gcc dot gnu dot org
2005-10-14 14:37 ` pinskia at gcc dot gnu dot org
2005-10-31  2:44 ` mmitchel at gcc dot gnu dot org
2006-05-25 20:26 ` mmitchel at gcc dot gnu dot org
2006-06-09  9:57 ` jakub at gcc dot gnu dot org
2006-06-10 22:23 ` pinskia at gcc dot gnu dot org
2006-07-03 23:52 ` tbm at cyrius dot com
2007-02-14  9:05 ` mmitchel at gcc dot gnu dot org

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=20050307223914.15195.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).