public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Klaus Rudolph <lts-rudolph@gmx.de>
To: David Brown <david.brown@hesbynett.no>,
	"Peter Sommerlad (C++)" <peter.cpp@sommerlad.ch>,
	"gcc-help@gcc.gnu.org" <gcc-help@gcc.gnu.org>,
	avr-gcc-list@nongnu.org
Subject: Re: static class member as interrupt handler works, but not if class is templated
Date: Mon, 12 Apr 2021 16:56:24 +0200	[thread overview]
Message-ID: <2a76e1e2-7c9e-cc8e-4543-65c39d01d895@gmx.de> (raw)
In-Reply-To: <e7c1552b-8a33-3a65-8da9-83e98a19faca@hesbynett.no>

Am 12.04.21 um 15:46 schrieb David Brown:

> Certainly templates can be instantiated zero, once, or multiple times.
> And certainly some templates are intended only to be instantiated a
> single time.  But it would surely be difficult to have a feature that
> only works when there is a single instantiation.

You don't have to be worry about. If it is instantiated zero times,
nothing happens, if it instantiates once, it gets the new name, if it
instantiates multiple times, it get multiple instances with the same
name and fails during linking. Absolutely fine!



>
> There is also the issue of linkage of the names here.  A template
> instantiation has function/method names that are mangled with the
> template type, template parameters, parameter types, etc.  These have a
> particular kind of linkage that lets the toolchain (compiler, assembler
> and linker) know that they can be defined in more than one unit, and at
> link time one of them (by unspecified choice) can be picked for the
> final binary.  An assembly-defined specific name for an interrupt
> vector, on the other hand, is a C external linkage name that can only be
> defined once.  I don't see that these two uses could easily be combined.

There should be anything combined. The templated instance simply should
have the name from asm statement which has C linkage.


>
> It seems natural to me that a feature which can only be relevant to a
> single instantiation of a template should be connected to an
> instantiation, not a definition.  This is particularly true when the
> details of the attribute you want - the "vector" assembly name - are
> dependent on a non-type parameter for the template.

The opposite is meant! It is intended by using the asm statement that we
have a single name, fully independent of parameters for the template.

Klaus

  reply	other threads:[~2021-04-12 14:56 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-10 13:33 Klaus Rudolph
2021-04-10 15:26 ` Jonathan Wakely
2021-04-10 19:36   ` Trampas Stern
2021-04-10 20:11   ` Klaus
2021-04-11 12:21     ` David Brown
2021-04-11 23:33       ` Trampas Stern
2021-04-12  9:20 ` Peter Sommerlad (C++)
2021-04-12 11:16   ` Klaus Rudolph
2021-04-12 11:53     ` Matthijs Kooijman
2021-04-12 12:12       ` Klaus Rudolph
2021-04-12 13:46         ` David Brown
2021-04-12 14:56           ` Klaus Rudolph [this message]
2021-04-12 14:25         ` Anton Staaf
2021-04-12 15:06           ` Klaus Rudolph

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2a76e1e2-7c9e-cc8e-4543-65c39d01d895@gmx.de \
    --to=lts-rudolph@gmx.de \
    --cc=avr-gcc-list@nongnu.org \
    --cc=david.brown@hesbynett.no \
    --cc=gcc-help@gcc.gnu.org \
    --cc=peter.cpp@sommerlad.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).