public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110323] New: Code for explicit instantiation of template method of template class
@ 2023-06-20 15:57 stlim0727 at gmail dot com
  2023-06-20 16:12 ` [Bug c++/110323] [11/12/13/14 Regression] Code for explicit instantiation of template method of template class not generated pinskia at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: stlim0727 at gmail dot com @ 2023-06-20 15:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110323

            Bug ID: 110323
           Summary: Code for explicit instantiation of template method of
                    template class
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: stlim0727 at gmail dot com
  Target Milestone: ---

Code for explicit instantiation of a template method of a class is not
generated with following code:

$ cat > test.cpp
#include <type_traits>

constexpr int VAL = 1;

struct foo {
    template <int B>
    void bar(typename std::conditional<B==VAL, int, float>::type arg) {
    }
};

template void foo::bar<1>(int arg);

Code is not generated for g++11 and above versions:
$ g++12 -S -o- -c test.cpp
        .file   "test.cpp"
        .text
        .section        .rodata
        .align 4
        .type   _ZL3VAL, @object
        .size   _ZL3VAL, 4
_ZL3VAL:
        .long   1
        .ident  "GCC: (GNU) 12.1.1 20220628 (Red Hat 12.1.1-3)"
        .section        .note.GNU-stack,"",@progbits

However, the code is generated if I replace "B==VAL" with "B==1" or if I use
g++10 and below versions:
$ g++8 -S -o- -c test.cpp
        .file   "test.cpp"
        .text
        .section        .rodata
        .align 4
        .type   _ZL3VAL, @object
        .size   _ZL3VAL, 4
_ZL3VAL:
        .long   1
        .section       
.text._ZN3foo3barILi1EEEvNSt11conditionalIXeqT_L_ZL3VALEEifE4typeE,"axG",@progbits,_ZN3foo3barILi1EEEvNSt11conditionalIXeqT_L_ZL3VALEEifE4typeE,comdat
        .align 2
        .weak   _ZN3foo3barILi1EEEvNSt11conditionalIXeqT_L_ZL3VALEEifE4typeE
        .type   _ZN3foo3barILi1EEEvNSt11conditionalIXeqT_L_ZL3VALEEifE4typeE,
@function
_ZN3foo3barILi1EEEvNSt11conditionalIXeqT_L_ZL3VALEEifE4typeE:
.LFB9:
        .cfi_startproc
        pushq   %rbp
        .cfi_def_cfa_offset 16
        .cfi_offset 6, -16
        movq    %rsp, %rbp
        .cfi_def_cfa_register 6
        movq    %rdi, -8(%rbp)
        movl    %esi, -12(%rbp)
        nop
        popq    %rbp
        .cfi_def_cfa 7, 8
        ret
        .cfi_endproc
.LFE9:
        .size   _ZN3foo3barILi1EEEvNSt11conditionalIXeqT_L_ZL3VALEEifE4typeE,
.-_ZN3foo3barILi1EEEvNSt11conditionalIXeqT_L_ZL3VALEEifE4typeE
        .ident  "GCC: (GNU) 8.5.0 20210514 (Red Hat 8.5.0-18)"
        .section        .note.GNU-stack,"",@progbits

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

end of thread, other threads:[~2024-03-21 17:55 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-20 15:57 [Bug c++/110323] New: Code for explicit instantiation of template method of template class stlim0727 at gmail dot com
2023-06-20 16:12 ` [Bug c++/110323] [11/12/13/14 Regression] Code for explicit instantiation of template method of template class not generated pinskia at gcc dot gnu.org
2024-03-05 20:47 ` mpolacek at gcc dot gnu.org
2024-03-05 20:49 ` mpolacek at gcc dot gnu.org
2024-03-05 21:39 ` mpolacek at gcc dot gnu.org
2024-03-05 22:56 ` mpolacek at gcc dot gnu.org
2024-03-06 14:53 ` mpolacek at gcc dot gnu.org
2024-03-07 15:23 ` mpolacek at gcc dot gnu.org
2024-03-08 17:25 ` ppalka at gcc dot gnu.org
2024-03-08 17:43 ` mpolacek at gcc dot gnu.org
2024-03-08 17:47 ` mpolacek at gcc dot gnu.org
2024-03-21 17:54 ` cvs-commit at gcc dot gnu.org
2024-03-21 17:55 ` [Bug c++/110323] [11/12/13 " mpolacek at gcc dot gnu.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).