public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110128] New: copy attribute does not copy from template specializations
@ 2023-06-05 15:45 jwjagersma at gmail dot com
  2023-06-05 16:00 ` [Bug c++/110128] " jwjagersma at gmail dot com
  0 siblings, 1 reply; 2+ messages in thread
From: jwjagersma at gmail dot com @ 2023-06-05 15:45 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110128
           Summary: copy attribute does not copy from template
                    specializations
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jwjagersma at gmail dot com
  Target Milestone: ---

Given the following example:


    template<int>
    void check_num();

    template<> [[gnu::warning("unlucky number")]]
    void check_num<13>();

    template<> [[gnu::error("evil number")]]
    void check_num<666>();


    template<int I> [[gnu::copy(check_num<I>)]]
    int num() { return I; }

    int main()
    {
        return num<42>() + num<13>() + num<666>();
    }


GCC only produces a number of -Wattributes warnings:


    $ g++ test-copy.cpp
    test-copy.cpp: In substitution of ‘template<int I> int num() [with int I =
42]’:
    test-copy.cpp:16:19:   required from here
    test-copy.cpp:12:5: warning: ‘copy’ attribute ignored on a declaration of a
different kind than referenced symbol [-Wattributes]
       12 | int num() { return I; }
          |     ^~~
    test-copy.cpp: In substitution of ‘template<int I> int num() [with int I =
13]’:
    test-copy.cpp:16:31:   required from here
    test-copy.cpp:12:5: warning: ‘copy’ attribute ignored on a declaration of a
different kind than referenced symbol [-Wattributes]
    test-copy.cpp: In substitution of ‘template<int I> int num() [with int I =
666]’:
    test-copy.cpp:16:44:   required from here
    test-copy.cpp:12:5: warning: ‘copy’ attribute ignored on a declaration of a
different kind than referenced symbol [-Wattributes]


PR89309 claims these are only spurious, but in this case they are not.  The
attributes are not copied.

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

* [Bug c++/110128] copy attribute does not copy from template specializations
  2023-06-05 15:45 [Bug c++/110128] New: copy attribute does not copy from template specializations jwjagersma at gmail dot com
@ 2023-06-05 16:00 ` jwjagersma at gmail dot com
  0 siblings, 0 replies; 2+ messages in thread
From: jwjagersma at gmail dot com @ 2023-06-05 16:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from jwjagersma at gmail dot com ---
Additionally, the following example does not produce any -Wattributes warnings
at all, but the attributes are still not copied:


    template<int>
    struct check_num
    {
        static void check();
    };

    template<>
    struct check_num<13>
    {
        [[gnu::warning("unlucky number")]]
        static void check();
    };

    template<>
    struct check_num<666>
    {
        [[gnu::error("evil number")]]
        static void check();
    };


    template<int I> [[gnu::copy(check_num<I>::check)]]
    int num() { return I; }

    int main()
    {
        return num<42>() + num<13>() + num<666>();
    }

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

end of thread, other threads:[~2023-06-05 16:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-05 15:45 [Bug c++/110128] New: copy attribute does not copy from template specializations jwjagersma at gmail dot com
2023-06-05 16:00 ` [Bug c++/110128] " jwjagersma at gmail 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).