From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by sourceware.org (Postfix) with ESMTPS id A2F8A3850405 for ; Mon, 12 Apr 2021 14:26:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A2F8A3850405 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=socialhacker.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=anton@socialhacker.com Received: by mail-ej1-x631.google.com with SMTP id w3so20623682ejc.4 for ; Mon, 12 Apr 2021 07:26:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=socialhacker-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4a+nXp02dunB1P59534THcBMtv6q95inCq9Eg/bhrW0=; b=fWOKxGy24CEpcfKV5zhAVzfrCxYpT7RtGzEwruJr2j2uw45m34D7BL37LkjWVwLvNf uG48WlKXjXoAmpSILDNGroz2zAQ9+uhnrAkb61bL1M9qC2VJRlLZtymMsx2fjEj8xO7E 3pJvy5pig0H6DUYLxWqMzFd5BPNS1GKKY+gvEUBaK+4JpFm/0NxB3mCz101AkL1nSiV+ xSCP6nZekwNbV5hxN1gCUd4uhy/Ra4V74DZUZ2HVLcOqK7u38JfD/zhvwyc8fQFnVpgV jLnz4Tf8a5QsTNH1WYQ2Pk7VbtaUkXAotoSyzDaeaxAF8Briotrn40LAU5OXAjchYWQ4 tiyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4a+nXp02dunB1P59534THcBMtv6q95inCq9Eg/bhrW0=; b=I67d9qdIK6oBNXOMYzNQyF5PP0m8A98qeKtwej19JJHU/8A452fEEWaAeSn4g4vDwc VeCAgFAhJtqZ5C6hRDJw6C+sZtyK1CEy2yOqZQauWougQFYNGb9wEMYjiV8UEJvG5BxB yg2/kuDULyyXicrjbQ4OriDFaC6h5QPwAH2Rmow/gSgJQvqEBGI3fm7NAKQbECjYKvz0 PF1e0a8vkeIhRRSyw8MplB9nImgX79CTdROD4xH1LjgdjUQ7rsfUONkzVmBPoxelUDh7 G7kCET5og0aBIa7pIcqkmsBlQLV7Jg2fuG5aTksHd7YtlCw99vstsjq76dja73CqKRe0 PWsQ== X-Gm-Message-State: AOAM533IZthNRZ5sbFmWPVgY3X2jX1m66fqRRLVagXWRmOmvHMV4zuXT R9akEM/5zb4oCXGwAQtAlZguwgzcA9KieJpx4TWwrQ== X-Google-Smtp-Source: ABdhPJxxw5+iqAH8ilC8wwuZXjGafpMNrim2Ndxp25ui3JgLoeGirVuonb9JxM392d6fwFH2yDkBEcb0twzzSe6ctng= X-Received: by 2002:a17:906:b251:: with SMTP id ce17mr5997552ejb.333.1618237567279; Mon, 12 Apr 2021 07:26:07 -0700 (PDT) MIME-Version: 1.0 References: <5f39cb4e-a445-bf19-ae90-b76c934aa930@gmx.de> <38829120-5ab7-d74e-0149-edf8ec6d4227@sommerlad.ch> <20210412115337.GB250@login.tika.stderr.nl> In-Reply-To: From: Anton Staaf Date: Mon, 12 Apr 2021 07:25:55 -0700 Message-ID: Subject: Re: static class member as interrupt handler works, but not if class is templated To: Klaus Rudolph Cc: "Peter Sommerlad (C++)" , "gcc-help@gcc.gnu.org" , avr-gcc-list@nongnu.org X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, HTML_MESSAGE, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Apr 2021 14:26:10 -0000 Klaus, I'm not sure if my previous answer didn't make it through or was just missed, but I believe your problem is related to this GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70435 -Anton On Mon, Apr 12, 2021 at 5:14 AM Klaus Rudolph wrote: > Am 12.04.21 um 13:53 schrieb Matthijs Kooijman: > >>> - figure out, where the special handling of the __vector_10 seems to > >>> happen, and why it is not happening in the class template case. This > >>> might help diagnose if and where to fix it within the compiler. > >> > >> That is compiler internals... yes, if it is a compiler bug, it is the > >> way to have a solution. But in that case, it seems to be a generic > >> problem for gcc as attributes are not assigned to any templated class > >> member functions. No idea if this is related to the target ( avr ) or > >> generic for all platforms. But I never did any change inside the > >> compiler. Any help is welcome! > > > > My suspiciou would be that this is a generic gcc problem, where the > > "asm" attribute is not honoured for template functions. It probably also > > makes some sense, since a template is intended to be instantiated > > multiple times, and each instantiation gets a name that is generated > > based on (I believe) the template arguments passed, so I suspect that > > the "generate a name for this template instantiation" code doesn't look > > at the asm attribute. > > > > Also note that *if* it would, then each instantiation would use the same > > name and multiple instanations would result in duplicate symbols. If you > > would bring this up as a gcc bug, I wouldn't be surprised that it would > > be closed as wontfix for this reason. > > I disagree as a template "always" would be instantiated multiple times. > And even if it would be, the linker will fire a error message, as it > sees multiple definitions. So there is no "general" problem in > "renaming" a templated function. It simply *can* work. > > But it looks that not only the "renaming" stuff did not work, all the > flags are not handled with the templated function. Looks like that the > asm declaration did not find its target :-) > > > > > Another workaround that I think hasn't been suggested yet, would be to > > just define a global `__vector_10` function and from that just call your > > templated static member. > > That is the classical way "we" all work. And it optimizes well in that > case as the code from the static templated member is fully inlined. But > it is still a workaround and it simply breaks standard c++ coding. Yes, > we can write C with classes, but I simply dislike :-) > > > Combined with the `always_inline` attribute, > > you can ensure that the call is inlined and there is no runtime overhead > > (with LTO, this probably already happens when there's just a single call > > to the member). > > It already optimizes well in O2 if templated member function and free > handler definition is in same translation unit. > > Klaus > > >