public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/17386] New: libstdc++ iostreams miscompilation
@ 2004-09-09 23:53 rth at gcc dot gnu dot org
  2004-09-10  0:06 ` [Bug c++/17386] " rth at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: rth at gcc dot gnu dot org @ 2004-09-09 23:53 UTC (permalink / raw)
  To: gcc-bugs

Originally reported as http://gcc.gnu.org/ml/gcc-regression/2004-09/msg00008.html,
can be reproduced with just

#include <iostream>
int main() {
  std::cout << 0L;
}

for a segfaulting testcase.  Obviously the miscompilation is in the library
itself.  More analysis to come...

-- 
           Summary: libstdc++ iostreams miscompilation
           Product: gcc
           Version: 4.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: rth at gcc dot gnu dot org
        ReportedBy: rth at gcc dot gnu dot org
                CC: apinski at apple dot com,gcc-bugs at gcc dot gnu dot
                    org,mrs at apple dot com


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


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

* [Bug c++/17386] libstdc++ iostreams miscompilation
  2004-09-09 23:53 [Bug c++/17386] New: libstdc++ iostreams miscompilation rth at gcc dot gnu dot org
@ 2004-09-10  0:06 ` rth at gcc dot gnu dot org
  2004-09-10  0:41 ` [Bug c++/17386] [4.0 Regression] " pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rth at gcc dot gnu dot org @ 2004-09-10  0:06 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rth at gcc dot gnu dot org  2004-09-10 00:06 -------
The problem is that locale_init.cc is miscompiled.  Specifically, the
initialization of _ZN14__gnu_internal9num_put_cE in _ZNSt6locale5_ImplC2Ej
has two initializations of its vptr (fine), and the stores get interchanged
by the scheduler (not fine), because alias analysis sez that the stores do
not conflict.

A minimal test case is

struct A
{
  virtual void a();
  int x;
};
                                                                                
struct C : public A
{
  virtual void a();
};
                                                                                
inline void* operator new(__SIZE_TYPE__, void* __p) throw() { return __p; }
                                                                                
extern C obj;
                                                                                
void foo()
{
  new(&obj) C;
}

Examining the assembly at -O2 -fomit-frame-pointer we see

        movl    $_ZTV1A+8, obj
        movl    $_ZTV1C+8, obj
        ret

If alias analysis were working properly, we'd expect the first store to
be eliminated as dead.  By the rtl optimizer, at least, since we don't
do any field-level dead store elimination at the tree level at the moment.

The problem, I believe, is in the front end.  Looking at the last tree dump,

  obj.<D1575>._vptr.A = &_ZTV1A[2];
  obj._vptr.A = &_ZTV1C[2];

Obviously, the vptr field is at the same location in the base class as it
is in the derived class.  Yet we are accessing the field different ways.
I have not yet determined class C has a separate FIELD_DECL for this vptr,
or if we're simply applying the FIELD_DECL from class A to an object of
class C.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu dot org


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


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

* [Bug c++/17386] [4.0 Regression] libstdc++ iostreams miscompilation
  2004-09-09 23:53 [Bug c++/17386] New: libstdc++ iostreams miscompilation rth at gcc dot gnu dot org
  2004-09-10  0:06 ` [Bug c++/17386] " rth at gcc dot gnu dot org
@ 2004-09-10  0:41 ` pinskia at gcc dot gnu dot org
  2004-09-10  0:47 ` rth at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-10  0:41 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-09-10 00:41 -------
Confirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|apinski at apple dot com    |pinskia at gcc dot gnu dot
                   |                            |org
           Severity|normal                      |critical
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-09-10 00:41:28
               date|                            |
            Summary|libstdc++ iostreams         |[4.0 Regression] libstdc++
                   |miscompilation              |iostreams miscompilation
   Target Milestone|---                         |4.0.0


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


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

* [Bug c++/17386] [4.0 Regression] libstdc++ iostreams miscompilation
  2004-09-09 23:53 [Bug c++/17386] New: libstdc++ iostreams miscompilation rth at gcc dot gnu dot org
  2004-09-10  0:06 ` [Bug c++/17386] " rth at gcc dot gnu dot org
  2004-09-10  0:41 ` [Bug c++/17386] [4.0 Regression] " pinskia at gcc dot gnu dot org
@ 2004-09-10  0:47 ` rth at gcc dot gnu dot org
  2004-09-10  0:48 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rth at gcc dot gnu dot org @ 2004-09-10  0:47 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|critical                    |normal
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2004-09-10 00:41:28         |2004-09-10 00:47:21
               date|                            |
   Target Milestone|4.0.0                       |---
            Version|4.0.0                       |2.95


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


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

* [Bug c++/17386] [4.0 Regression] libstdc++ iostreams miscompilation
  2004-09-09 23:53 [Bug c++/17386] New: libstdc++ iostreams miscompilation rth at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2004-09-10  0:47 ` rth at gcc dot gnu dot org
@ 2004-09-10  0:48 ` pinskia at gcc dot gnu dot org
  2004-09-10 21:42 ` cvs-commit at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-10  0:48 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.0.0
            Version|2.95                        |4.0.0


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


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

* [Bug c++/17386] [4.0 Regression] libstdc++ iostreams miscompilation
  2004-09-09 23:53 [Bug c++/17386] New: libstdc++ iostreams miscompilation rth at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2004-09-10  0:48 ` pinskia at gcc dot gnu dot org
@ 2004-09-10 21:42 ` cvs-commit at gcc dot gnu dot org
  2004-09-10 21:44 ` rth at gcc dot gnu dot org
  2004-09-11 22:11 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-09-10 21:42 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-09-10 21:42 -------
Subject: Bug 17386

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	rth@gcc.gnu.org	2004-09-10 21:42:01

Modified files:
	gcc/cp         : ChangeLog call.c class.c typeck.c 

Log message:
	PR c++/17386
	* call.c (build_vfield_ref): Move...
	* class.c (build_vfield_ref): ... here.  Convert datum to the
	primary base containing the vptr.
	(make_new_vtable): Simplify build_primary_vtable arguments.
	(finish_struct_1): Do not duplicate TYPE_VFIELD.
	* typeck.c (build_class_member_access_expr): Don't warn for
	null object access to base fields.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4343&r2=1.4344
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&r1=1.504&r2=1.505
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/class.c.diff?cvsroot=gcc&r1=1.669&r2=1.670
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&r1=1.574&r2=1.575



-- 


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


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

* [Bug c++/17386] [4.0 Regression] libstdc++ iostreams miscompilation
  2004-09-09 23:53 [Bug c++/17386] New: libstdc++ iostreams miscompilation rth at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2004-09-10 21:42 ` cvs-commit at gcc dot gnu dot org
@ 2004-09-10 21:44 ` rth at gcc dot gnu dot org
  2004-09-11 22:11 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: rth at gcc dot gnu dot org @ 2004-09-10 21:44 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rth at gcc dot gnu dot org  2004-09-10 21:44 -------
http://gcc.gnu.org/ml/gcc-patches/2004-09/msg01018.html

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


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


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

* [Bug c++/17386] [4.0 Regression] libstdc++ iostreams miscompilation
  2004-09-09 23:53 [Bug c++/17386] New: libstdc++ iostreams miscompilation rth at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2004-09-10 21:44 ` rth at gcc dot gnu dot org
@ 2004-09-11 22:11 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-11 22:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-09-11 22:11 -------
*** Bug 17420 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rearnsha at gcc dot gnu dot
                   |                            |org


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


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

end of thread, other threads:[~2004-09-11 22:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-09 23:53 [Bug c++/17386] New: libstdc++ iostreams miscompilation rth at gcc dot gnu dot org
2004-09-10  0:06 ` [Bug c++/17386] " rth at gcc dot gnu dot org
2004-09-10  0:41 ` [Bug c++/17386] [4.0 Regression] " pinskia at gcc dot gnu dot org
2004-09-10  0:47 ` rth at gcc dot gnu dot org
2004-09-10  0:48 ` pinskia at gcc dot gnu dot org
2004-09-10 21:42 ` cvs-commit at gcc dot gnu dot org
2004-09-10 21:44 ` rth at gcc dot gnu dot org
2004-09-11 22:11 ` 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).