* Possible bug in gcc-10.2 with non-type template parameter
@ 2021-01-04 20:48 Edward Diener
2021-01-06 20:51 ` Stefan Ring
0 siblings, 1 reply; 3+ messages in thread
From: Edward Diener @ 2021-01-04 20:48 UTC (permalink / raw)
To: gcc-help
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 ?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Possible bug in gcc-10.2 with non-type template parameter
2021-01-04 20:48 Possible bug in gcc-10.2 with non-type template parameter Edward Diener
@ 2021-01-06 20:51 ` Stefan Ring
2021-01-06 21:55 ` Edward Diener
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Ring @ 2021-01-06 20:51 UTC (permalink / raw)
To: Edward Diener; +Cc: gcc-help
On Mon, Jan 4, 2021 at 9:49 PM Edward Diener
<eldlistmailingz@tropicsoft.com> wrote:
>
> 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 ?
Hmm, I'm not a language lawyer, and the error message does not seem to
make sense, but what happens when you remove the offending line in
your real program?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Possible bug in gcc-10.2 with non-type template parameter
2021-01-06 20:51 ` Stefan Ring
@ 2021-01-06 21:55 ` Edward Diener
0 siblings, 0 replies; 3+ messages in thread
From: Edward Diener @ 2021-01-06 21:55 UTC (permalink / raw)
To: gcc-help
On 1/6/2021 3:51 PM, Stefan Ring via Gcc-help wrote:
> On Mon, Jan 4, 2021 at 9:49 PM Edward Diener
> <eldlistmailingz@tropicsoft.com> wrote:
>>
>> 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 ?
>
> Hmm, I'm not a language lawyer, and the error message does not seem to
> make sense, but what happens when you remove the offending line in
> your real program?
A workaround which works with gcc-10.2 as pointed out to me is:
static atmp<T,&ast<T>::avar> acst;
instead of:
static atmp<T,&avar> acst;
However the workaround should not be needed and indeed is not needed by
clang or VC++. I have reported this bug to gcc at
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98523.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-01-06 21:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-04 20:48 Possible bug in gcc-10.2 with non-type template parameter Edward Diener
2021-01-06 20:51 ` Stefan Ring
2021-01-06 21:55 ` Edward Diener
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).