public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/15721] New: [3.5.0 regression] template instantation omits static data members
@ 2004-05-30 14:05 mec dot gnu at mindspring dot com
  2004-05-30 14:06 ` [Bug c++/15721] " mec dot gnu at mindspring dot com
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: mec dot gnu at mindspring dot com @ 2004-05-30 14:05 UTC (permalink / raw)
  To: gcc-bugs

Here is the test program:

template <typename T> class gnu_obj_2
{
  public:
    static int my_static;
};

template <typename T> int gnu_obj_2<T>::my_static = 117;

// instantiate templates explicitly so their static members will exist
template class gnu_obj_2 <int>;
template class gnu_obj_2 <long>;

int main ()
{
  gnu_obj_2 <int>  test_int;
  gnu_obj_2 <long> test_long;
  return 0;
}

I compile this program with "gcc -S -gstabs+".  Then I look in the generated
assembly code for the static data members gnu_obj_2<int>::my_static and
gnu_obj_2<long>::my_static.

(I don't think the -gstabs+ is important but I just happened to start with this
flag and have kept it all the way till now, sigh.  This code originally came
from the gdb test suite, gdb.cp/m-static.cc).

The explicit instantiations of gnu_obj_2<int> and gnu_obj_2<long> are supposed
to instantiate the static data members along with everything else, but they don't.

http://gcc.gnu.org/ml/gcc/2004-05/msg01394.html

The last working gcc was 2004-05-19 01:00:00 UTC and the first broken gcc was
2004-05-19 02:00:00 UTC.  The problem is with this patch:

http://gcc.gnu.org/ml/gcc-patches/2004-05/msg01157.html
IMA repairs: Don't use DECL_ASSEMBLER_NAME for a key in cgraph(take two)

I'll add three attachments: the test program; the last good assembly code; and
the first bad assembly code.

-- 
           Summary: [3.5.0 regression] template instantation omits static
                    data members
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P1
         Component: c++
        AssignedTo: zack at codesourcery dot com
        ReportedBy: mec dot gnu at mindspring dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug c++/15721] [3.5.0 regression] template instantation omits static data members
  2004-05-30 14:05 [Bug c++/15721] New: [3.5.0 regression] template instantation omits static data members mec dot gnu at mindspring dot com
@ 2004-05-30 14:06 ` mec dot gnu at mindspring dot com
  2004-05-30 14:10 ` mec dot gnu at mindspring dot com
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: mec dot gnu at mindspring dot com @ 2004-05-30 14:06 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mec dot gnu at mindspring dot com  2004-05-29 02:23 -------
Created an attachment (id=6424)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=6424&action=view)
Test program

Compile with: "gcc -S -gstabs+".

Look for gnu_obj_2<int>::my_static and gnu_obj_2<long>::my_static in the
generated code.


-- 


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


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

* [Bug c++/15721] [3.5.0 regression] template instantation omits static data members
  2004-05-30 14:05 [Bug c++/15721] New: [3.5.0 regression] template instantation omits static data members mec dot gnu at mindspring dot com
  2004-05-30 14:06 ` [Bug c++/15721] " mec dot gnu at mindspring dot com
@ 2004-05-30 14:10 ` mec dot gnu at mindspring dot com
  2004-05-30 14:17 ` mec dot gnu at mindspring dot com
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: mec dot gnu at mindspring dot com @ 2004-05-30 14:10 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mec dot gnu at mindspring dot com  2004-05-29 02:24 -------
Created an attachment (id=6425)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=6425&action=view)
assembly code, last good compiler, 2004-05-19 01:00:00 UTC

Generated assembly code with "gcc -S -gstabs+ template-static.cc".
This is with the last good compiler.


-- 


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


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

* [Bug c++/15721] [3.5.0 regression] template instantation omits static data members
  2004-05-30 14:05 [Bug c++/15721] New: [3.5.0 regression] template instantation omits static data members mec dot gnu at mindspring dot com
  2004-05-30 14:06 ` [Bug c++/15721] " mec dot gnu at mindspring dot com
  2004-05-30 14:10 ` mec dot gnu at mindspring dot com
@ 2004-05-30 14:17 ` mec dot gnu at mindspring dot com
  2004-05-30 14:35 ` pinskia at gcc dot gnu dot org
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: mec dot gnu at mindspring dot com @ 2004-05-30 14:17 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mec dot gnu at mindspring dot com  2004-05-29 02:25 -------
Created an attachment (id=6426)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=6426&action=view)
Generated code, first bad compiler, 2004-05-19 02:00:00 UTC

Code generated with "gcc -S -gstabs+ template-static.cc".
This is with the first bad compiler.


-- 


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


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

* [Bug c++/15721] [3.5.0 regression] template instantation omits static data members
  2004-05-30 14:05 [Bug c++/15721] New: [3.5.0 regression] template instantation omits static data members mec dot gnu at mindspring dot com
                   ` (2 preceding siblings ...)
  2004-05-30 14:17 ` mec dot gnu at mindspring dot com
@ 2004-05-30 14:35 ` pinskia at gcc dot gnu dot org
  2004-05-30 15:07 ` pinskia at gcc dot gnu dot org
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-30 14:35 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-29 02:52 -------
Confirmed,  I will try to figure out what is going on but if Zack beats me, I would not be made.

mark_decl_referenced is being called for the variable.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|zack at codesourcery dot com|zack at gcc dot gnu dot org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|                            |1
           Keywords|                            |wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2004-05-29 02:52:33
               date|                            |
   Target Milestone|---                         |3.5.0


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


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

* [Bug c++/15721] [3.5.0 regression] template instantation omits static data members
  2004-05-30 14:05 [Bug c++/15721] New: [3.5.0 regression] template instantation omits static data members mec dot gnu at mindspring dot com
                   ` (3 preceding siblings ...)
  2004-05-30 14:35 ` pinskia at gcc dot gnu dot org
@ 2004-05-30 15:07 ` pinskia at gcc dot gnu dot org
  2004-05-30 15:12 ` pinskia at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-30 15:07 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-29 03:04 -------
The problem is that decl is not finalized before being marked as needed.

-- 


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


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

* [Bug c++/15721] [3.5.0 regression] template instantation omits static data members
  2004-05-30 14:05 [Bug c++/15721] New: [3.5.0 regression] template instantation omits static data members mec dot gnu at mindspring dot com
                   ` (4 preceding siblings ...)
  2004-05-30 15:07 ` pinskia at gcc dot gnu dot org
@ 2004-05-30 15:12 ` pinskia at gcc dot gnu dot org
  2004-05-30 21:07 ` pinskia at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-30 15:12 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-29 03:33 -------
I know that rest_of_decl_compilation is being called for the decl but not assemble_variable for some 
reason.  I have not checked how it was done before Zack's patch.

-- 


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


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

* [Bug c++/15721] [3.5.0 regression] template instantation omits static data members
  2004-05-30 14:05 [Bug c++/15721] New: [3.5.0 regression] template instantation omits static data members mec dot gnu at mindspring dot com
                   ` (5 preceding siblings ...)
  2004-05-30 15:12 ` pinskia at gcc dot gnu dot org
@ 2004-05-30 21:07 ` pinskia at gcc dot gnu dot org
  2004-05-30 21:45 ` pinskia at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-30 21:07 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-29 20:39 -------
The difference between before and after is that DECL_EXTERNAL (decl) in rest_of_decl_compilation is 
true after but false before which causes it not be outputted.

-- 


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


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

* [Bug c++/15721] [3.5.0 regression] template instantation omits static data members
  2004-05-30 14:05 [Bug c++/15721] New: [3.5.0 regression] template instantation omits static data members mec dot gnu at mindspring dot com
                   ` (6 preceding siblings ...)
  2004-05-30 21:07 ` pinskia at gcc dot gnu dot org
@ 2004-05-30 21:45 ` pinskia at gcc dot gnu dot org
  2004-05-30 21:49 ` pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-30 21:45 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-29 22:25 -------
Ignore that last comment, I was wrong, it does not even get to rest_of_decl_compilation for that decl.

-- 


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


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

* [Bug c++/15721] [3.5.0 regression] template instantation omits static data members
  2004-05-30 14:05 [Bug c++/15721] New: [3.5.0 regression] template instantation omits static data members mec dot gnu at mindspring dot com
                   ` (7 preceding siblings ...)
  2004-05-30 21:45 ` pinskia at gcc dot gnu dot org
@ 2004-05-30 21:49 ` pinskia at gcc dot gnu dot org
  2004-06-02  0:42 ` pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-30 21:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-29 22:29 -------
Okay, wrapup_global_declarations checks TREE_SYMBOL_REFERENCED of DECL_ASSEMBLER_NAME of the 
decl which is where the problem is.

-- 


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


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

* [Bug c++/15721] [3.5.0 regression] template instantation omits static data members
  2004-05-30 14:05 [Bug c++/15721] New: [3.5.0 regression] template instantation omits static data members mec dot gnu at mindspring dot com
                   ` (8 preceding siblings ...)
  2004-05-30 21:49 ` pinskia at gcc dot gnu dot org
@ 2004-06-02  0:42 ` pinskia at gcc dot gnu dot org
  2004-06-02 20:08 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-02  0:42 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-06-02 00:42 -------
This should work (I have tested it on the testcase though), I have not bootstrapped and tested it yet:
Index: toplev.c
===============================================================
====
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.899
diff -u -p -r1.899 toplev.c
--- toplev.c    30 May 2004 18:32:27 -0000      1.899
+++ toplev.c    2 Jun 2004 00:41:09 -0000
@@ -1455,16 +1455,17 @@ wrapup_global_declarations (tree *vec, i
 
          if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl))
            {
+              struct cgraph_varpool_node *node;
              bool needed = 1;
+              node = cgraph_varpool_node (decl);
 
-             if (flag_unit_at_a_time
-                 && cgraph_varpool_node (decl)->finalized)
+             if (node && node->finalized)
                needed = 0;
              else if ((flag_unit_at_a_time && !cgraph_global_info_ready)
                       && (TREE_USED (decl)
                           || TREE_USED (DECL_ASSEMBLER_NAME (decl))))
                /* needed */;
-             else if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
+             else if (node && node->needed)
                /* needed */;
              else if (DECL_COMDAT (decl))
                needed = 0;

-- 


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


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

* [Bug c++/15721] [3.5.0 regression] template instantation omits static data members
  2004-05-30 14:05 [Bug c++/15721] New: [3.5.0 regression] template instantation omits static data members mec dot gnu at mindspring dot com
                   ` (9 preceding siblings ...)
  2004-06-02  0:42 ` pinskia at gcc dot gnu dot org
@ 2004-06-02 20:08 ` pinskia at gcc dot gnu dot org
  2004-06-19  6:22 ` [Bug c++/15721] [3.5 " pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-02 20:08 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-06-02 20:08 -------
Mine, I posted a patch: <http://gcc.gnu.org/ml/gcc-patches/2004-06/msg00088.html>.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |zack at gcc dot gnu dot org
         AssignedTo|zack at gcc dot gnu dot org |pinskia at gcc dot gnu dot
                   |                            |org
           Keywords|                            |patch


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


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

* [Bug c++/15721] [3.5 regression] template instantation omits static data members
  2004-05-30 14:05 [Bug c++/15721] New: [3.5.0 regression] template instantation omits static data members mec dot gnu at mindspring dot com
                   ` (10 preceding siblings ...)
  2004-06-02 20:08 ` pinskia at gcc dot gnu dot org
@ 2004-06-19  6:22 ` pinskia at gcc dot gnu dot org
  2004-06-19 10:26 ` giovannibajo at libero dot it
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-19  6:22 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |critical
            Summary|[3.5.0 regression] template |[3.5 regression] template
                   |instantation omits static   |instantation omits static
                   |data members                |data members


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


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

* [Bug c++/15721] [3.5 regression] template instantation omits static data members
  2004-05-30 14:05 [Bug c++/15721] New: [3.5.0 regression] template instantation omits static data members mec dot gnu at mindspring dot com
                   ` (11 preceding siblings ...)
  2004-06-19  6:22 ` [Bug c++/15721] [3.5 " pinskia at gcc dot gnu dot org
@ 2004-06-19 10:26 ` giovannibajo at libero dot it
  2004-06-19 16:17 ` cvs-commit at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: giovannibajo at libero dot it @ 2004-06-19 10:26 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-06-19 10:26 -------
Andrew, this patch was approved by Mark, I assume you just forgot to apply and 
close the bug...

-- 


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


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

* [Bug c++/15721] [3.5 regression] template instantation omits static data members
  2004-05-30 14:05 [Bug c++/15721] New: [3.5.0 regression] template instantation omits static data members mec dot gnu at mindspring dot com
                   ` (12 preceding siblings ...)
  2004-06-19 10:26 ` giovannibajo at libero dot it
@ 2004-06-19 16:17 ` cvs-commit at gcc dot gnu dot org
  2004-06-19 16:18 ` pinskia at gcc dot gnu dot org
  2004-06-22 21:52 ` mec dot gnu at mindspring dot com
  15 siblings, 0 replies; 17+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-06-19 16:17 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-06-19 16:17 -------
Subject: Bug 15721

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	pinskia@gcc.gnu.org	2004-06-19 16:17:01

Modified files:
	gcc            : ChangeLog toplev.c 

Log message:
	2004-06-19  Andrew Pinski  <apinski@apple.com>
	
	PR c++/15721
	* toplev.c (wrapup_global_declarations): Do not check
	TREE_SYMBOL_REFERENCED of the DECL_ASSEMBLER_NAME but check
	cgraph_varpool_node's needed field.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.4040&r2=2.4041
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/toplev.c.diff?cvsroot=gcc&r1=1.905&r2=1.906



-- 


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


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

* [Bug c++/15721] [3.5 regression] template instantation omits static data members
  2004-05-30 14:05 [Bug c++/15721] New: [3.5.0 regression] template instantation omits static data members mec dot gnu at mindspring dot com
                   ` (13 preceding siblings ...)
  2004-06-19 16:17 ` cvs-commit at gcc dot gnu dot org
@ 2004-06-19 16:18 ` pinskia at gcc dot gnu dot org
  2004-06-22 21:52 ` mec dot gnu at mindspring dot com
  15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-19 16:18 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-06-19 16:18 -------
No I was just testing it again.

Fixed now.

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


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


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

* [Bug c++/15721] [3.5 regression] template instantation omits static data members
  2004-05-30 14:05 [Bug c++/15721] New: [3.5.0 regression] template instantation omits static data members mec dot gnu at mindspring dot com
                   ` (14 preceding siblings ...)
  2004-06-19 16:18 ` pinskia at gcc dot gnu dot org
@ 2004-06-22 21:52 ` mec dot gnu at mindspring dot com
  15 siblings, 0 replies; 17+ messages in thread
From: mec dot gnu at mindspring dot com @ 2004-06-22 21:52 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mec dot gnu at mindspring dot com  2004-06-22 21:52 -------
Subject: Re:  [3.5 regression] template instantation omits static data members

It works for me.
Thanks, Michael C



-- 


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


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

end of thread, other threads:[~2004-06-22 21:52 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-30 14:05 [Bug c++/15721] New: [3.5.0 regression] template instantation omits static data members mec dot gnu at mindspring dot com
2004-05-30 14:06 ` [Bug c++/15721] " mec dot gnu at mindspring dot com
2004-05-30 14:10 ` mec dot gnu at mindspring dot com
2004-05-30 14:17 ` mec dot gnu at mindspring dot com
2004-05-30 14:35 ` pinskia at gcc dot gnu dot org
2004-05-30 15:07 ` pinskia at gcc dot gnu dot org
2004-05-30 15:12 ` pinskia at gcc dot gnu dot org
2004-05-30 21:07 ` pinskia at gcc dot gnu dot org
2004-05-30 21:45 ` pinskia at gcc dot gnu dot org
2004-05-30 21:49 ` pinskia at gcc dot gnu dot org
2004-06-02  0:42 ` pinskia at gcc dot gnu dot org
2004-06-02 20:08 ` pinskia at gcc dot gnu dot org
2004-06-19  6:22 ` [Bug c++/15721] [3.5 " pinskia at gcc dot gnu dot org
2004-06-19 10:26 ` giovannibajo at libero dot it
2004-06-19 16:17 ` cvs-commit at gcc dot gnu dot org
2004-06-19 16:18 ` pinskia at gcc dot gnu dot org
2004-06-22 21:52 ` mec dot gnu at mindspring dot com

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