public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/13081] New: [3.3 regression] forward template declarations in <complex> let inlining fail
@ 2003-11-17  0:06 debian-gcc at lists dot debian dot org
  2003-11-17  0:52 ` [Bug c++/13081] [3.3/3.4 " pinskia at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: debian-gcc at lists dot debian dot org @ 2003-11-17  0:06 UTC (permalink / raw)
  To: gcc-bugs

[ forwarded from http://bugs.debian.org/195264 ]

the bug submitter noticed, that std::conj() doesn't get inlined, as one'd expect
it to be, when compiling the following with -O2

template<typename T> T foo(T);
 
template<typename T> inline T foo(T t)
{
  return t;
} // __attribute((always_inline))
 
long bar (long);
 
inline long bar (long l)
{
  return l;
}
 
void doo (long &l)
{
  l = foo (l);
  l = bar (l);
}


Disassembly of section .text:

00000000 <doo(long&)>:
   0:   55                      push   %ebp
   1:   89 e5                   mov    %esp,%ebp
   3:   53                      push   %ebx
   4:   83 ec 10                sub    $0x10,%esp
   7:   8b 5d 08                mov    0x8(%ebp),%ebx
   a:   ff 33                   pushl  (%ebx)
   c:   e8 fc ff ff ff          call   d <doo(long&)+0xd>
                        d: R_386_PC32   long foo<long>(long)
  11:   89 03                   mov    %eax,(%ebx)
  13:   83 c4 10                add    $0x10,%esp
  16:   8b 5d fc                mov    0xfffffffc(%ebp),%ebx
  19:   c9                      leave  
  1a:   c3                      ret    
Disassembly of section .gnu.linkonce.t._Z3fooIlET_S0_:

00000000 <long foo<long>(long)>:
   0:   55                      push   %ebp
   1:   89 e5                   mov    %esp,%ebp
   3:   8b 45 08                mov    0x8(%ebp),%eax
   6:   c9                      leave  
   7:   c3                      ret    


i.e. bar get's inlined, but foo<long> does not... why?
btw, gcc-2.95 would optimize it into a NOP:

00000000 <doo(long &)>:
   0:   55                      push   %ebp
   1:   89 e5                   mov    %esp,%ebp
   3:   c9                      leave  
   4:   c3                      ret    

-- I'd say that's a regression...

-- 
           Summary: [3.3 regression] forward template declarations in
                    <complex> let inlining fail
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: debian-gcc at lists dot debian dot org
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug c++/13081] [3.3/3.4 regression] forward template declarations in <complex> let inlining fail
  2003-11-17  0:06 [Bug libstdc++/13081] New: [3.3 regression] forward template declarations in <complex> let inlining fail debian-gcc at lists dot debian dot org
@ 2003-11-17  0:52 ` pinskia at gcc dot gnu dot org
  2003-12-16 21:32 ` pinskia at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-11-17  0:52 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-11-17 00:52 -------
The problem is somehow related to having this line:
template<typename T> T foo(T);

Confirmed on the mainline and 3.3.2.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
          Component|libstdc++                   |c++
     Ever Confirmed|                            |1
           Keywords|                            |pessimizes-code
   Last reconfirmed|0000-00-00 00:00:00         |2003-11-17 00:52:07
               date|                            |
            Summary|[3.3 regression] forward    |[3.3/3.4 regression] forward
                   |template declarations in    |template declarations in
                   |<complex> let inlining fail |<complex> let inlining fail
   Target Milestone|---                         |3.3.3


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


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

* [Bug c++/13081] [3.3/3.4 regression] forward template declarations in <complex> let inlining fail
  2003-11-17  0:06 [Bug libstdc++/13081] New: [3.3 regression] forward template declarations in <complex> let inlining fail debian-gcc at lists dot debian dot org
  2003-11-17  0:52 ` [Bug c++/13081] [3.3/3.4 " pinskia at gcc dot gnu dot org
@ 2003-12-16 21:32 ` pinskia at gcc dot gnu dot org
  2003-12-25  1:34 ` pinskia at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-16 21:32 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-12-16 20:31 -------
Some how the template is being marked as not inlinable (it does not inline even at -O3).

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2003-11-17 00:52:07         |2003-12-16 20:31:48
               date|                            |


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


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

* [Bug c++/13081] [3.3/3.4 regression] forward template declarations in <complex> let inlining fail
  2003-11-17  0:06 [Bug libstdc++/13081] New: [3.3 regression] forward template declarations in <complex> let inlining fail debian-gcc at lists dot debian dot org
  2003-11-17  0:52 ` [Bug c++/13081] [3.3/3.4 " pinskia at gcc dot gnu dot org
  2003-12-16 21:32 ` pinskia at gcc dot gnu dot org
@ 2003-12-25  1:34 ` pinskia at gcc dot gnu dot org
  2003-12-25 17:52 ` pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-25  1:34 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-12-25 00:27 -------
Too much changes for 3.3.3 to fix this one.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.3.3                       |3.4.0


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


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

* [Bug c++/13081] [3.3/3.4 regression] forward template declarations in <complex> let inlining fail
  2003-11-17  0:06 [Bug libstdc++/13081] New: [3.3 regression] forward template declarations in <complex> let inlining fail debian-gcc at lists dot debian dot org
                   ` (2 preceding siblings ...)
  2003-12-25  1:34 ` pinskia at gcc dot gnu dot org
@ 2003-12-25 17:52 ` pinskia at gcc dot gnu dot org
  2003-12-25 17:54 ` pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-25 17:52 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-12-25 16:46 -------
Maybe I was wrong, this might be fixable for 3.3.3.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4.0                       |3.3.3


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


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

* [Bug c++/13081] [3.3/3.4 regression] forward template declarations in <complex> let inlining fail
  2003-11-17  0:06 [Bug libstdc++/13081] New: [3.3 regression] forward template declarations in <complex> let inlining fail debian-gcc at lists dot debian dot org
                   ` (3 preceding siblings ...)
  2003-12-25 17:52 ` pinskia at gcc dot gnu dot org
@ 2003-12-25 17:54 ` pinskia at gcc dot gnu dot org
  2003-12-29  2:44 ` cvs-commit at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-25 17:54 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-12-25 17:24 -------
The problem is that the followard template declaration:
template<typename T> T foo(T);
Causes all template functions not be defined as inline.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2003-12-16 20:31:48         |2003-12-25 17:24:05
               date|                            |


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


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

* [Bug c++/13081] [3.3/3.4 regression] forward template declarations in <complex> let inlining fail
  2003-11-17  0:06 [Bug libstdc++/13081] New: [3.3 regression] forward template declarations in <complex> let inlining fail debian-gcc at lists dot debian dot org
                   ` (4 preceding siblings ...)
  2003-12-25 17:54 ` pinskia at gcc dot gnu dot org
@ 2003-12-29  2:44 ` cvs-commit at gcc dot gnu dot org
  2003-12-29  5:32 ` [Bug c++/13081] [3.3 " mmitchel at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2003-12-29  2:44 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2003-12-29 02:42 -------
Subject: Bug 13081

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2003-12-29 02:42:17

Modified files:
	gcc/cp         : ChangeLog decl.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/opt: inline6.C 
	gcc/testsuite/g++.dg/parse: error9.C 

Log message:
	PR c++/13081
	* decl.c (duplicate_decls): Preserve inline-ness when redeclaring
	a function template.
	
	PR c++/12613
	* decl.c (reshape_init): Reject GNU colon-style designated
	initializers in arrays.
	
	PR c++/13081
	* g++.dg/opt/inline6.C: New test.
	
	PR c++/12613
	* g++.dg/parse/error9.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3837&r2=1.3838
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1168&r2=1.1169
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3315&r2=1.3316
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/inline6.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/error9.C.diff?cvsroot=gcc&r1=NONE&r2=1.1



-- 


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


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

* [Bug c++/13081] [3.3 regression] forward template declarations in <complex> let inlining fail
  2003-11-17  0:06 [Bug libstdc++/13081] New: [3.3 regression] forward template declarations in <complex> let inlining fail debian-gcc at lists dot debian dot org
                   ` (5 preceding siblings ...)
  2003-12-29  2:44 ` cvs-commit at gcc dot gnu dot org
@ 2003-12-29  5:32 ` mmitchel at gcc dot gnu dot org
  2003-12-29 17:08 ` doko at cs dot tu-berlin dot de
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2003-12-29  5:32 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2003-12-29 02:44 -------
Fixed in GCC 3.4.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[3.3/3.4 regression] forward|[3.3 regression] forward
                   |template declarations in    |template declarations in
                   |<complex> let inlining fail |<complex> let inlining fail


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


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

* [Bug c++/13081] [3.3 regression] forward template declarations in <complex> let inlining fail
  2003-11-17  0:06 [Bug libstdc++/13081] New: [3.3 regression] forward template declarations in <complex> let inlining fail debian-gcc at lists dot debian dot org
                   ` (6 preceding siblings ...)
  2003-12-29  5:32 ` [Bug c++/13081] [3.3 " mmitchel at gcc dot gnu dot org
@ 2003-12-29 17:08 ` doko at cs dot tu-berlin dot de
  2004-01-01  0:22 ` gdr at integrable-solutions dot net
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: doko at cs dot tu-berlin dot de @ 2003-12-29 17:08 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From doko at cs dot tu-berlin dot de  2003-12-29 17:00 -------
Subject: Re:  [3.3/3.4 regression] forward template declarations in <complex> let inlining fail

> Module name:	gcc
> Changes by:	mmitchel@gcc.gnu.org	2003-12-29 02:42:17
> 
> Modified files:
> 	gcc/cp         : ChangeLog decl.c 
> 	gcc/testsuite  : ChangeLog 
> Added files:
> 	gcc/testsuite/g++.dg/opt: inline6.C 
> 	gcc/testsuite/g++.dg/parse: error9.C 
> 
> Log message:
> 	PR c++/13081
> 	* decl.c (duplicate_decls): Preserve inline-ness when redeclaring
> 	a function template.
> 	
> 	PR c++/13081
> 	* g++.dg/opt/inline6.C: New test.

backported to the gcc-3_3-branch, no regressions on an i486-linux
bootstrap. Ok for the branch?

2003-12-28  Mark Mitchell  <mark@codesourcery.com>

	PR c++/13081
 	* decl.c (duplicate_decls): Preserve inline-ness when redeclaring
 	a function template.
 
 	PR c++/13081
 	* g++.dg/opt/inline6.C: New test.

--- gcc/testsuite/g++.dg/opt/inline6.C
+++ gcc/testsuite/g++.dg/opt/inline6.C	2003-12-29 09:12:36.000000000 +0000
@@ -0,0 +1,14 @@
+// PR c++/13081
+// { dg-options "-O2" }
+// { dg-final { scan-assembler-not "foo" } }
+
+template<typename T> T foo(T);
+ 
+template<typename T> inline T foo(T t)
+{
+  return t;
+}
+
+void bar (long& l) {
+  l = foo(l);
+}

--- gcc/cp/decl.c~	2003-12-29 10:18:13.000000000 +0100
+++ gcc/cp/decl.c	2003-12-29 10:25:57.000000000 +0100
@@ -3737,6 +3737,14 @@
 	    = DECL_SOURCE_LOCATION (newdecl);
 	}
 
+      if (DECL_FUNCTION_TEMPLATE_P (newdecl))
+	{
+	  DECL_INLINE (DECL_TEMPLATE_RESULT (olddecl)) 
+	    |= DECL_INLINE (DECL_TEMPLATE_RESULT (newdecl));
+	  DECL_DECLARED_INLINE_P (DECL_TEMPLATE_RESULT (olddecl))
+	    |= DECL_DECLARED_INLINE_P (DECL_TEMPLATE_RESULT (newdecl));
+	}
+
       return 1;
     }
 


-- 


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


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

* [Bug c++/13081] [3.3 regression] forward template declarations in <complex> let inlining fail
  2003-11-17  0:06 [Bug libstdc++/13081] New: [3.3 regression] forward template declarations in <complex> let inlining fail debian-gcc at lists dot debian dot org
                   ` (7 preceding siblings ...)
  2003-12-29 17:08 ` doko at cs dot tu-berlin dot de
@ 2004-01-01  0:22 ` gdr at integrable-solutions dot net
  2004-01-02 11:15 ` cvs-commit at gcc dot gnu dot org
  2004-01-02 11:42 ` debian-gcc at lists dot debian dot org
  10 siblings, 0 replies; 12+ messages in thread
From: gdr at integrable-solutions dot net @ 2004-01-01  0:22 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gdr at integrable-solutions dot net  2004-01-01 00:22 -------
Subject: Re:  [3.3/3.4 regression] forward template declarations in <complex> let inlining fail

Matthias Klose <doko@cs.tu-berlin.de> writes:

| > Module name:	gcc
| > Changes by:	mmitchel@gcc.gnu.org	2003-12-29 02:42:17
| > 
| > Modified files:
| > 	gcc/cp         : ChangeLog decl.c 
| > 	gcc/testsuite  : ChangeLog 
| > Added files:
| > 	gcc/testsuite/g++.dg/opt: inline6.C 
| > 	gcc/testsuite/g++.dg/parse: error9.C 
| > 
| > Log message:
| > 	PR c++/13081
| > 	* decl.c (duplicate_decls): Preserve inline-ness when redeclaring
| > 	a function template.
| > 	
| > 	PR c++/13081
| > 	* g++.dg/opt/inline6.C: New test.
| 
| backported to the gcc-3_3-branch, no regressions on an i486-linux
| bootstrap. Ok for the branch?

Yes, thanks.

-- Gaby


-- 


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


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

* [Bug c++/13081] [3.3 regression] forward template declarations in <complex> let inlining fail
  2003-11-17  0:06 [Bug libstdc++/13081] New: [3.3 regression] forward template declarations in <complex> let inlining fail debian-gcc at lists dot debian dot org
                   ` (8 preceding siblings ...)
  2004-01-01  0:22 ` gdr at integrable-solutions dot net
@ 2004-01-02 11:15 ` cvs-commit at gcc dot gnu dot org
  2004-01-02 11:42 ` debian-gcc at lists dot debian dot org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-01-02 11:15 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-01-02 11:15 -------
Subject: Bug 13081

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	doko@gcc.gnu.org	2004-01-02 11:15:04

Modified files:
	gcc/cp         : decl.c ChangeLog 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/opt: inline6.C 

Log message:
	2004-01-02  Matthias Klose  <doko@debian.org>
	
	Backport from mainline:
	2003-12-28  Mark Mitchell  <mark@codesourcery.com>
	
	PR c++/13081
	* decl.c (duplicate_decls): Preserve inline-ness when redeclaring
	a function template.
	
	PR c++/13081
	* g++.dg/opt/inline6.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/inline6.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.4.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.965.2.69&r2=1.965.2.70
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.234&r2=1.3076.2.235
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.350&r2=1.2261.2.351



-- 


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


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

* [Bug c++/13081] [3.3 regression] forward template declarations in <complex> let inlining fail
  2003-11-17  0:06 [Bug libstdc++/13081] New: [3.3 regression] forward template declarations in <complex> let inlining fail debian-gcc at lists dot debian dot org
                   ` (9 preceding siblings ...)
  2004-01-02 11:15 ` cvs-commit at gcc dot gnu dot org
@ 2004-01-02 11:42 ` debian-gcc at lists dot debian dot org
  10 siblings, 0 replies; 12+ messages in thread
From: debian-gcc at lists dot debian dot org @ 2004-01-02 11:42 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From debian-gcc at lists dot debian dot org  2004-01-02 11:42 -------
Fixed on the 3.3 branch as well.

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


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


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

end of thread, other threads:[~2004-01-02 11:42 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-17  0:06 [Bug libstdc++/13081] New: [3.3 regression] forward template declarations in <complex> let inlining fail debian-gcc at lists dot debian dot org
2003-11-17  0:52 ` [Bug c++/13081] [3.3/3.4 " pinskia at gcc dot gnu dot org
2003-12-16 21:32 ` pinskia at gcc dot gnu dot org
2003-12-25  1:34 ` pinskia at gcc dot gnu dot org
2003-12-25 17:52 ` pinskia at gcc dot gnu dot org
2003-12-25 17:54 ` pinskia at gcc dot gnu dot org
2003-12-29  2:44 ` cvs-commit at gcc dot gnu dot org
2003-12-29  5:32 ` [Bug c++/13081] [3.3 " mmitchel at gcc dot gnu dot org
2003-12-29 17:08 ` doko at cs dot tu-berlin dot de
2004-01-01  0:22 ` gdr at integrable-solutions dot net
2004-01-02 11:15 ` cvs-commit at gcc dot gnu dot org
2004-01-02 11:42 ` debian-gcc at lists dot debian 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).