public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/23708] New: Non-inline function incorrectly treated as inline when using precompiled headers
@ 2005-09-03  1:57 jconner at apple dot com
  2005-09-03  2:09 ` [Bug c++/23708] " jconner at apple dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: jconner at apple dot com @ 2005-09-03  1:57 UTC (permalink / raw)
  To: gcc-bugs

The non-inline specialization of an inline member function of a template class is not being treated as 
inline when using precompiled headers.

For example, consider

  test.H:
    template <class T> class simple_class {
      public:
        inline void testfn (T);
    };

  test.C:
    #include "test.H"

    template <> void simple_class<int>::testfn (int) {}

    int main (int argc, char *argv[])
    {
      simple_class<int> sc1;
      sc1.testfn (5);
    }

When compiled without precompiled headers, the function appears a simple global function:

        .global _ZN12simple_classIiE6testfnEi

But when test.H is first compiled (with "g++ test.H") into a PCH, and then test.C is compiled, the 
function appears as a weak symbol in a COMDAT section, implying that g++ is considering the 
specialization "inline" even though it isn't marked as such.

        .section        .text._ZN12simple_classIiE6testfnEi,"axG",%
progbits,_ZN12simple_classIiE6testfnEi,comdat
        .align  2
        .weak   _ZN12simple_classIiE6testfnEi
        .type   _ZN12simple_classIiE6testfnEi, %function

-- 
           Summary: Non-inline function incorrectly treated as inline when
                    using precompiled headers
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jconner at apple dot com
                CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: arm-none-elf


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


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

* [Bug c++/23708] Non-inline function incorrectly treated as inline when using precompiled headers
  2005-09-03  1:57 [Bug c++/23708] New: Non-inline function incorrectly treated as inline when using precompiled headers jconner at apple dot com
@ 2005-09-03  2:09 ` jconner at apple dot com
  2005-09-03  2:11 ` [Bug c++/23708] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: jconner at apple dot com @ 2005-09-03  2:09 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jconner at apple dot com  2005-09-03 02:09 -------
When generating a precompiled header, finish_member_declaration() invokes note_decl_for_pch() for 
the function "testfn<T>", and assigns it to the COMDAT section with weak linkage.

Then, when the test.C file is compiled, a function "testfn<int> (implicit declaration)" is generated, and 
inherits the COMDAT properties of "testfn<T>".  Finally, when the explicit specialization is actually 
seen, the function duplicate_decls() attempts to merge the declarations, and assigns the specialization 
function (incorrectly) to the COMDAT section.

When not using precompiled headers, the "testfn<T>" function is not assigned to the COMDAT section 
until after its attributes are merged with the specialization by duplicate_decls(), and since checks are 
already in place to make sure that the specialization doesn't inherit the DECL_DECLARED_INLINE_P 
attribute (which is a prerequesite for ending up in COMDAT), both decls are assigned to the correct 
sections.


-- 


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


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

* [Bug c++/23708] [4.0/4.1 Regression] Non-inline function incorrectly treated as inline when using precompiled headers
  2005-09-03  1:57 [Bug c++/23708] New: Non-inline function incorrectly treated as inline when using precompiled headers jconner at apple dot com
  2005-09-03  2:09 ` [Bug c++/23708] " jconner at apple dot com
@ 2005-09-03  2:11 ` pinskia at gcc dot gnu dot org
  2005-09-08 19:55 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-09-03  2:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-09-03 02:11 -------
Confirmed, a regression from 3.4.0.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |wrong-code
      Known to fail|                            |4.0.0 4.1.0
      Known to work|                            |3.4.0
   Last reconfirmed|0000-00-00 00:00:00         |2005-09-03 02:11:07
               date|                            |
            Summary|Non-inline function         |[4.0/4.1 Regression] Non-
                   |incorrectly treated as      |inline function incorrectly
                   |inline when using           |treated as inline when using
                   |precompiled headers         |precompiled headers
   Target Milestone|---                         |4.0.2


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


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

* [Bug c++/23708] [4.0/4.1 Regression] Non-inline function incorrectly treated as inline when using precompiled headers
  2005-09-03  1:57 [Bug c++/23708] New: Non-inline function incorrectly treated as inline when using precompiled headers jconner at apple dot com
  2005-09-03  2:09 ` [Bug c++/23708] " jconner at apple dot com
  2005-09-03  2:11 ` [Bug c++/23708] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
@ 2005-09-08 19:55 ` pinskia at gcc dot gnu dot org
  2005-09-09 16:38 ` [Bug c++/23708] [4.0 " mmitchel at gcc dot gnu dot org
  2005-09-27 16:17 ` mmitchel at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-09-08 19:55 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-09-08 19:55 -------
Patch posted here: <http://gcc.gnu.org/ml/gcc-patches/2005-09/msg00449.html>.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |http://gcc.gnu.org/ml/gcc-
                   |                            |patches/2005-
                   |                            |09/msg00449.html
           Keywords|                            |patch


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


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

* [Bug c++/23708] [4.0 Regression] Non-inline function incorrectly treated as inline when using precompiled headers
  2005-09-03  1:57 [Bug c++/23708] New: Non-inline function incorrectly treated as inline when using precompiled headers jconner at apple dot com
                   ` (2 preceding siblings ...)
  2005-09-08 19:55 ` pinskia at gcc dot gnu dot org
@ 2005-09-09 16:38 ` mmitchel at gcc dot gnu dot org
  2005-09-27 16:17 ` mmitchel at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-09-09 16:38 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2005-09-09 16:38 -------
Fixed in 4.1 by the patch for 22252.  This isn't quite a "duplicate" bug so I'm
leaving the bug open; it's conceivable that we'd fix this bug, without fixing
22252, for 4.0.x.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.0/4.1 Regression] Non-   |[4.0 Regression] Non-inline
                   |inline function incorrectly |function incorrectly treated
                   |treated as inline when using|as inline when using
                   |precompiled headers         |precompiled headers


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


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

* [Bug c++/23708] [4.0 Regression] Non-inline function incorrectly treated as inline when using precompiled headers
  2005-09-03  1:57 [Bug c++/23708] New: Non-inline function incorrectly treated as inline when using precompiled headers jconner at apple dot com
                   ` (3 preceding siblings ...)
  2005-09-09 16:38 ` [Bug c++/23708] [4.0 " mmitchel at gcc dot gnu dot org
@ 2005-09-27 16:17 ` mmitchel at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-09-27 16:17 UTC (permalink / raw)
  To: gcc-bugs



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


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


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

end of thread, other threads:[~2005-09-27 16:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-03  1:57 [Bug c++/23708] New: Non-inline function incorrectly treated as inline when using precompiled headers jconner at apple dot com
2005-09-03  2:09 ` [Bug c++/23708] " jconner at apple dot com
2005-09-03  2:11 ` [Bug c++/23708] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
2005-09-08 19:55 ` pinskia at gcc dot gnu dot org
2005-09-09 16:38 ` [Bug c++/23708] [4.0 " mmitchel at gcc dot gnu dot org
2005-09-27 16:17 ` mmitchel 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).