public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/25895]  New: [4.0/4.1/4.2 Regression] wrong code with ?: and derived class pointers
@ 2006-01-21  2:34 pinskia at gcc dot gnu dot org
  2006-01-21  2:34 ` [Bug c++/25895] " pinskia at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-21  2:34 UTC (permalink / raw)
  To: gcc-bugs

Testcase:
#include <stdlib.h>
class base {
        public:
                base() {}
        private:
                int val_;
};

class derived : public base {
        public:
                derived() {}
};

bool x = true ? (derived*)0 : (base*)0;

int main ()
{
  if (x)
    abort();
}


-- 
           Summary: [4.0/4.1/4.2 Regression] wrong code with ?: and derived
                    class pointers
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/25895] [4.0/4.1/4.2 Regression] wrong code with ?: and derived class pointers
  2006-01-21  2:34 [Bug c++/25895] New: [4.0/4.1/4.2 Regression] wrong code with ?: and derived class pointers pinskia at gcc dot gnu dot org
@ 2006-01-21  2:34 ` pinskia at gcc dot gnu dot org
  2006-01-21  2:47 ` pinskia at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-21  2:34 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.0.4


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/25895] [4.0/4.1/4.2 Regression] wrong code with ?: and derived class pointers
  2006-01-21  2:34 [Bug c++/25895] New: [4.0/4.1/4.2 Regression] wrong code with ?: and derived class pointers pinskia at gcc dot gnu dot org
  2006-01-21  2:34 ` [Bug c++/25895] " pinskia at gcc dot gnu dot org
@ 2006-01-21  2:47 ` pinskia at gcc dot gnu dot org
  2006-01-21 18:49 ` mmitchel at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-21  2:47 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.0.4                       |4.0.3


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/25895] [4.0/4.1/4.2 Regression] wrong code with ?: and derived class pointers
  2006-01-21  2:34 [Bug c++/25895] New: [4.0/4.1/4.2 Regression] wrong code with ?: and derived class pointers pinskia at gcc dot gnu dot org
  2006-01-21  2:34 ` [Bug c++/25895] " pinskia at gcc dot gnu dot org
  2006-01-21  2:47 ` pinskia at gcc dot gnu dot org
@ 2006-01-21 18:49 ` mmitchel at gcc dot gnu dot org
  2006-01-21 19:02 ` mmitchel at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-01-21 18:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from mmitchel at gcc dot gnu dot org  2006-01-21 18:49 -------
This regression comes from the changes that were made (by Jason, I believe) to
use base class FIELD_DECLs to perform casts from derived to base classes,
rather than just pointer arithmetic.  

In build_base_path, we decide not to generate an explicit test for NULL because
we've noticed that the base class is at offset zero relative to the derived
class, and therefore we know that the conversion will be a no-op.  As an
optimization, we avoid generating the NULL test.

We end up with:

  ADDR_EXPR (COMPONENT_REF (INDIRECT_REF 0) (FIELD_DECL base))

which c_common_truthvalue_conversions "knows" must be non-NULL.

I believe that in the case that we know that the conversion is a no-op, we
should just return a NOP_EXPR, rather than going through the fields.

This is a P1.


-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at redhat dot com
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Priority|P3                          |P1
   Last reconfirmed|0000-00-00 00:00:00         |2006-01-21 18:49:07
               date|                            |


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/25895] [4.0/4.1/4.2 Regression] wrong code with ?: and derived class pointers
  2006-01-21  2:34 [Bug c++/25895] New: [4.0/4.1/4.2 Regression] wrong code with ?: and derived class pointers pinskia at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2006-01-21 18:49 ` mmitchel at gcc dot gnu dot org
@ 2006-01-21 19:02 ` mmitchel at gcc dot gnu dot org
  2006-01-22  0:41 ` mmitchel at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-01-21 19:02 UTC (permalink / raw)
  To: gcc-bugs



-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |mark at codesourcery dot com
                   |dot org                     |
             Status|NEW                         |ASSIGNED


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/25895] [4.0/4.1/4.2 Regression] wrong code with ?: and derived class pointers
  2006-01-21  2:34 [Bug c++/25895] New: [4.0/4.1/4.2 Regression] wrong code with ?: and derived class pointers pinskia at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2006-01-21 19:02 ` mmitchel at gcc dot gnu dot org
@ 2006-01-22  0:41 ` mmitchel at gcc dot gnu dot org
  2006-01-22  0:42 ` mmitchel at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-01-22  0:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from mmitchel at gcc dot gnu dot org  2006-01-22 00:41 -------
Subject: Bug 25895

Author: mmitchel
Date: Sun Jan 22 00:40:56 2006
New Revision: 110082

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110082
Log:
        PR c++/25895
        * class.c (build_base_path): Generate a NOP_EXPR instead of a
        COMPONENT_REF if the base and derived classes are at the same
        address.
        PR c++/25856
        * decl.c (begin_destructor_body): Robustify.
        PR c++/25858 
        * parser.c (cp_parser_direct_declarator): Robustify.

        PR c++/25895
        * g++.dg/inherit/conv2.C: New test.
        PR c++/25856
        * g++.dg/parse/dtor7.C: New test.
        PR c++/25858
        * g++.dg/template/crash44.C: New test.

Added:
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/inherit/conv2.C
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/parse/dtor7.C
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/template/crash44.C
Modified:
    branches/gcc-4_0-branch/gcc/cp/ChangeLog
    branches/gcc-4_0-branch/gcc/cp/class.c
    branches/gcc-4_0-branch/gcc/cp/decl.c
    branches/gcc-4_0-branch/gcc/cp/parser.c
    branches/gcc-4_0-branch/gcc/testsuite/ChangeLog


-- 


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/25895] [4.0/4.1/4.2 Regression] wrong code with ?: and derived class pointers
  2006-01-21  2:34 [Bug c++/25895] New: [4.0/4.1/4.2 Regression] wrong code with ?: and derived class pointers pinskia at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2006-01-22  0:42 ` mmitchel at gcc dot gnu dot org
@ 2006-01-22  0:42 ` mmitchel at gcc dot gnu dot org
  2006-01-22  0:52 ` mmitchel at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-01-22  0:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from mmitchel at gcc dot gnu dot org  2006-01-22 00:42 -------
Subject: Bug 25895

Author: mmitchel
Date: Sun Jan 22 00:41:58 2006
New Revision: 110083

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110083
Log:
        PR c++/25895
        * class.c (build_base_path): Generate a NOP_EXPR instead of a
        COMPONENT_REF if the base and derived classes are at the same
        address.
        PR c++/25856
        * decl.c (begin_destructor_body): Robustify.
        PR c++/25858 
        * parser.c (cp_parser_direct_declarator): Robustify.

        PR c++/25895
        * g++.dg/inherit/conv2.C: New test.
        PR c++/25856
        * g++.dg/parse/dtor7.C: New test.
        PR c++/25858
        * g++.dg/template/crash44.C: New test.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/inherit/conv2.C
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/parse/dtor7.C
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/template/crash44.C
Modified:
    branches/gcc-4_1-branch/gcc/cp/ChangeLog
    branches/gcc-4_1-branch/gcc/cp/class.c
    branches/gcc-4_1-branch/gcc/cp/decl.c
    branches/gcc-4_1-branch/gcc/cp/parser.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog


-- 


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/25895] [4.0/4.1/4.2 Regression] wrong code with ?: and derived class pointers
  2006-01-21  2:34 [Bug c++/25895] New: [4.0/4.1/4.2 Regression] wrong code with ?: and derived class pointers pinskia at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2006-01-22  0:41 ` mmitchel at gcc dot gnu dot org
@ 2006-01-22  0:42 ` mmitchel at gcc dot gnu dot org
  2006-01-22  0:42 ` mmitchel at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-01-22  0:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from mmitchel at gcc dot gnu dot org  2006-01-22 00:42 -------
Subject: Bug 25895

Author: mmitchel
Date: Sun Jan 22 00:42:40 2006
New Revision: 110084

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110084
Log:
        PR c++/25895
        * class.c (build_base_path): Generate a NOP_EXPR instead of a
        COMPONENT_REF if the base and derived classes are at the same
        address.
        PR c++/25856
        * decl.c (begin_destructor_body): Robustify.
        PR c++/25858 
        * parser.c (cp_parser_direct_declarator): Robustify.

        PR c++/25895
        * g++.dg/inherit/conv2.C: New test.
        PR c++/25856
        * g++.dg/parse/dtor7.C: New test.
        PR c++/25858
        * g++.dg/template/crash44.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/inherit/conv2.C
    trunk/gcc/testsuite/g++.dg/parse/dtor7.C
    trunk/gcc/testsuite/g++.dg/template/crash44.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/class.c
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/25895] [4.0/4.1/4.2 Regression] wrong code with ?: and derived class pointers
  2006-01-21  2:34 [Bug c++/25895] New: [4.0/4.1/4.2 Regression] wrong code with ?: and derived class pointers pinskia at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2006-01-22  0:42 ` mmitchel at gcc dot gnu dot org
@ 2006-01-22  0:52 ` mmitchel at gcc dot gnu dot org
  2007-04-14 23:54 ` jason at gcc dot gnu dot org
  2007-04-14 23:59 ` pinskia at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-01-22  0:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from mmitchel at gcc dot gnu dot org  2006-01-22 00:52 -------
Fixed in 4.0.3.


-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/25895] [4.0/4.1/4.2 Regression] wrong code with ?: and derived class pointers
  2006-01-21  2:34 [Bug c++/25895] New: [4.0/4.1/4.2 Regression] wrong code with ?: and derived class pointers pinskia at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2006-01-22  0:52 ` mmitchel at gcc dot gnu dot org
@ 2007-04-14 23:54 ` jason at gcc dot gnu dot org
  2007-04-14 23:59 ` pinskia at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: jason at gcc dot gnu dot org @ 2007-04-14 23:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jason at gcc dot gnu dot org  2007-04-15 00:54 -------
I believe that this change will pessimize alias analysis somewhat; improved
alias analysis was the reason for my change to model base access with
COMPONENT_REF.  But I'll leave this alone until I get around to doing that more
fully (as described in 22488)


-- 


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/25895] [4.0/4.1/4.2 Regression] wrong code with ?: and derived class pointers
  2006-01-21  2:34 [Bug c++/25895] New: [4.0/4.1/4.2 Regression] wrong code with ?: and derived class pointers pinskia at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2007-04-14 23:54 ` jason at gcc dot gnu dot org
@ 2007-04-14 23:59 ` pinskia at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-04-14 23:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pinskia at gcc dot gnu dot org  2007-04-15 00:58 -------
(In reply to comment #6)
> I believe that this change will pessimize alias analysis somewhat; improved
> alias analysis was the reason for my change to model base access with
> COMPONENT_REF.  But I'll leave this alone until I get around to doing that more
> fully (as described in 22488)

Also I think Honza's patch for fold actually might fix this up after the C++
producing the "crazy" code.


-- 


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2007-04-14 23:59 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-21  2:34 [Bug c++/25895] New: [4.0/4.1/4.2 Regression] wrong code with ?: and derived class pointers pinskia at gcc dot gnu dot org
2006-01-21  2:34 ` [Bug c++/25895] " pinskia at gcc dot gnu dot org
2006-01-21  2:47 ` pinskia at gcc dot gnu dot org
2006-01-21 18:49 ` mmitchel at gcc dot gnu dot org
2006-01-21 19:02 ` mmitchel at gcc dot gnu dot org
2006-01-22  0:41 ` mmitchel at gcc dot gnu dot org
2006-01-22  0:42 ` mmitchel at gcc dot gnu dot org
2006-01-22  0:42 ` mmitchel at gcc dot gnu dot org
2006-01-22  0:52 ` mmitchel at gcc dot gnu dot org
2007-04-14 23:54 ` jason at gcc dot gnu dot org
2007-04-14 23:59 ` pinskia at gcc dot gnu dot org

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