public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Edward Diener <eldlistmailingz@tropicsoft.com>
To: gcc-help@gcc.gnu.org
Subject: Possible bug in gcc-10.2 with non-type template parameter
Date: Mon, 4 Jan 2021 15:48:18 -0500	[thread overview]
Message-ID: <rsvuuh$342$1@ciao.gmane.io> (raw)

The code, called test_predicate.cpp, simplified from a much more 
elaborate implementation:

template < typename T, T *d >  class atmp { atmp() {} };

template < typename T > struct ast
     {
     static T avar;
     static atmp<T,&avar> acst;
     };

template < typename T > T ast<T>::avar;
template < typename T > atmp<T,&ast<T>::avar> ast<T>::acst;

int main()
    {
    return 0;
    }

The command line compile flags for gcc-10.2:

-fvisibility-inlines-hidden -Wno-unused-local-typedefs 
-ftrack-macro-expansion=0 -Wno-unused-variable 
-D_GLIBCXX_USE_CXX11_ABI=1 -Wa,-mbig-obj -m64 -mthreads -O0 -fno-inline 
-Wall -g -fvisibility=hidden -std=c++11 -c

The result:

test_predicate.cpp:10:47: error: conflicting declaration 'atmp<T, (& 
ast<T>::avar)> ast<T>::acst'
    10 | template < typename T > atmp<T,&ast<T>::avar> ast<T>::acst;
       |                                               ^~~~~~
test_predicate.cpp:6:26: note: previous declaration as 'atmp<T, (& 
ast<T>::avar)> ast<T>::acst'
     6 |     static atmp<T,&avar> acst;
       |                          ^~~~

The same source compiled with clang-11.0 and VC++14.2 succeeds with no 
error.

Is this s bug in gcc ? If so, is there a known workaround ?








             reply	other threads:[~2021-01-04 20:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-04 20:48 Edward Diener [this message]
2021-01-06 20:51 ` Stefan Ring
2021-01-06 21:55   ` Edward Diener

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='rsvuuh$342$1@ciao.gmane.io' \
    --to=eldlistmailingz@tropicsoft.com \
    --cc=gcc-help@gcc.gnu.org \
    /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).