public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/67594] New: Bug on partial specialization? Incomplete type.
@ 2015-09-15 22:00 vincent.lextrait at gmail dot com
2015-09-15 22:23 ` [Bug c++/67594] " vincent.lextrait at gmail dot com
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: vincent.lextrait at gmail dot com @ 2015-09-15 22:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67594
Bug ID: 67594
Summary: Bug on partial specialization? Incomplete type.
Product: gcc
Version: 4.9.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: vincent.lextrait at gmail dot com
Target Milestone: ---
# 1 "foo.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "foo.cpp"
template <typename B, int I=1> class C{};
template <int I> class C<float,I>{};
template <> class C<float>: public C<float,1>{};
C<float> c;
When compiled with:
/usr/local/bin/gcc-4.9 -c foo.cpp
Issues:
foo.cpp:3:36: error: invalid use of incomplete type 'class C<float>'
template <> class C<float>: public C<float,1>{};
^
foo.cpp:3:19: error: declaration of 'class C<float>'
template <> class C<float>: public C<float,1>{};
^
I do not see anything incomplete there.
gcc version 4.9.2:
Using built-in specs.
COLLECT_GCC=/usr/local/bin/gcc-4.9
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/4.9.2_1/libexec/gcc/x86_64-apple-darwin14.3.0/4.9.2/lto-wrapper
Target: x86_64-apple-darwin14.3.0
Configured with: ../configure --build=x86_64-apple-darwin14.3.0
--prefix=/usr/local/Cellar/gcc/4.9.2_1
--libdir=/usr/local/Cellar/gcc/4.9.2_1/lib/gcc/4.9
--enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-4.9
--with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr
--with-mpc=/usr/local/opt/libmpc --with-cloog=/usr/local/opt/cloog
--with-isl=/usr/local/opt/isl --with-system-zlib --enable-libstdcxx-time=yes
--enable-stage1-checking --enable-checking=release --enable-lto
--with-build-config=bootstrap-debug --disable-werror
--with-pkgversion='Homebrew gcc 4.9.2_1'
--with-bugurl=https://github.com/Homebrew/homebrew/issues --enable-plugin
--disable-nls --enable-multilib
Thread model: posix
gcc version 4.9.2 (Homebrew gcc 4.9.2_1)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/67594] Bug on partial specialization? Incomplete type.
2015-09-15 22:00 [Bug c++/67594] New: Bug on partial specialization? Incomplete type vincent.lextrait at gmail dot com
@ 2015-09-15 22:23 ` vincent.lextrait at gmail dot com
2015-09-15 23:00 ` redi at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: vincent.lextrait at gmail dot com @ 2015-09-15 22:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67594
--- Comment #1 from Vincent <vincent.lextrait at gmail dot com> ---
I've changed gcc version to 5.2, as 5.2 issues the same error.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/67594] Bug on partial specialization? Incomplete type.
2015-09-15 22:00 [Bug c++/67594] New: Bug on partial specialization? Incomplete type vincent.lextrait at gmail dot com
2015-09-15 22:23 ` [Bug c++/67594] " vincent.lextrait at gmail dot com
@ 2015-09-15 23:00 ` redi at gcc dot gnu.org
2015-09-15 23:02 ` vincent.lextrait at gmail dot com
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2015-09-15 23:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67594
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The partial specialization C<float> uses the default template argument, so is
identical to C<float, 1>, so you have tried to make it its own base class.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/67594] Bug on partial specialization? Incomplete type.
2015-09-15 22:00 [Bug c++/67594] New: Bug on partial specialization? Incomplete type vincent.lextrait at gmail dot com
2015-09-15 22:23 ` [Bug c++/67594] " vincent.lextrait at gmail dot com
2015-09-15 23:00 ` redi at gcc dot gnu.org
@ 2015-09-15 23:02 ` vincent.lextrait at gmail dot com
2015-09-15 23:27 ` redi at gcc dot gnu.org
2015-09-15 23:35 ` vincent.lextrait at gmail dot com
4 siblings, 0 replies; 6+ messages in thread
From: vincent.lextrait at gmail dot com @ 2015-09-15 23:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67594
--- Comment #3 from Vincent <vincent.lextrait at gmail dot com> ---
Oh, I see. So the first partial specialization is not "preferred" over the
general template?
(In reply to Jonathan Wakely from comment #2)
> The partial specialization C<float> uses the default template argument, so
> is identical to C<float, 1>, so you have tried to make it its own base class.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/67594] Bug on partial specialization? Incomplete type.
2015-09-15 22:00 [Bug c++/67594] New: Bug on partial specialization? Incomplete type vincent.lextrait at gmail dot com
` (2 preceding siblings ...)
2015-09-15 23:02 ` vincent.lextrait at gmail dot com
@ 2015-09-15 23:27 ` redi at gcc dot gnu.org
2015-09-15 23:35 ` vincent.lextrait at gmail dot com
4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2015-09-15 23:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67594
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The primary template defines the default argument for the second parameter.
The C<float,I> partial specialization is irrelevant, it isn't used.
The C<float> specialization is identical to C<float, 1> because it uses the
default argument, so if you write it like that then it should be obvious the
code is wrong:
template <typename B, int I=1> class C{};
template <int I> class C<float,I>{}; // unused
template <> class C<float, 1> : public C<float, 1> {};
^^^^^^^^^^^ ^^^^^^^^^^^
The base class matches the C<float, 1> specialization not the C<float, I>
partial specialization because C<float, 1> is more specialized.
So the base class is the same type, and of course a type cannot derive from
itself.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/67594] Bug on partial specialization? Incomplete type.
2015-09-15 22:00 [Bug c++/67594] New: Bug on partial specialization? Incomplete type vincent.lextrait at gmail dot com
` (3 preceding siblings ...)
2015-09-15 23:27 ` redi at gcc dot gnu.org
@ 2015-09-15 23:35 ` vincent.lextrait at gmail dot com
4 siblings, 0 replies; 6+ messages in thread
From: vincent.lextrait at gmail dot com @ 2015-09-15 23:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67594
--- Comment #5 from Vincent <vincent.lextrait at gmail dot com> ---
Thanks Jonathan to take the time. I have to reread the manual... Apologies for
using bandwidth.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-09-15 23:35 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-15 22:00 [Bug c++/67594] New: Bug on partial specialization? Incomplete type vincent.lextrait at gmail dot com
2015-09-15 22:23 ` [Bug c++/67594] " vincent.lextrait at gmail dot com
2015-09-15 23:00 ` redi at gcc dot gnu.org
2015-09-15 23:02 ` vincent.lextrait at gmail dot com
2015-09-15 23:27 ` redi at gcc dot gnu.org
2015-09-15 23:35 ` vincent.lextrait 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).