public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/55311] New: Cannot specialize template parameter of type 'const char *const' in 'using' alias
@ 2012-11-13 14:16 niels at penneman dot org
  2012-12-04 21:01 ` [Bug c++/55311] " niels at penneman dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: niels at penneman dot org @ 2012-11-13 14:16 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55311

             Bug #: 55311
           Summary: Cannot specialize template parameter of type 'const
                    char *const' in 'using' alias
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: niels@penneman.org


When providing arguments for a template class in a 'using' alias, specifying
arguments of type 'const char *const' doesn't work. It does work for an 'int'
pointer.

==========

GCC version:

$ gcc -###
Using built-in specs.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.0-alpha20121111/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.8.0-alpha20121111/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with:
/var/tmp/portage/sys-devel/gcc-4.8.0_alpha20121111/work/gcc-4.8-20121111/configure
--prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.0-alpha20121111
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0-alpha20121111/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0-alpha20121111
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0-alpha20121111/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0-alpha20121111/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0-alpha20121111/include/g++-v4
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec
--disable-fixed-point --with-ppl --with-cloog --disable-ppl-version-check
--with-cloog-include=/usr/include/cloog-ppl --enable-lto --enable-nls
--without-included-gettext --with-system-zlib --enable-obsolete
--disable-werror --enable-secureplt --enable-multilib
--with-multilib-list=m32,m64 --enable-libmudflap --disable-libssp
--enable-libgomp
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.8.0-alpha20121111/python
--enable-checking=release --disable-libgcj --disable-libquadmath
--enable-languages=c,c++ --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu --enable-targets=all
--with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo
4.8.0_alpha20121111'
Thread model: posix
gcc version 4.8.0-alpha20121111 20121111 (experimental) (Gentoo
4.8.0_alpha20121111)

==========

Code that fails to compile:

==========

template <const char *const C, typename T>
struct A
{};

extern constexpr char HELLO_WORLD[] = "hello world";

template <typename T>
using PartiallySpecialized = A<HELLO_WORLD, T>;

int main(int, char **)
{
        A<HELLO_WORLD, int> original;
        PartiallySpecialized<int> ps;
}

==========

Compiler invocation/output:

$ g++ -std=c++11 -Wall -Wextra strbug.cxx 
strbug.cxx:8:46: error: ‘"hello world"’ is not a valid template argument of
type ‘const char*’ because ‘"hello world"’ is not a variable
 using PartiallySpecialized = A<HELLO_WORLD, T>;
                                              ^
strbug.cxx: In function ‘int main(int, char**)’:
strbug.cxx:12:22: warning: unused variable ‘original’ [-Wunused-variable]
  A<HELLO_WORLD, int> original;
                      ^
strbug.cxx:13:28: warning: unused variable ‘ps’ [-Wunused-variable]
  PartiallySpecialized<int> ps;
                            ^

==========

Notice the first instantiation ('original') does not generate any errors or
warnings. The second instantiation ('ps') should be identical to the second.
Above code compiles without warnings and without errors on Clang 3.1.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-01-07 11:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-13 14:16 [Bug c++/55311] New: Cannot specialize template parameter of type 'const char *const' in 'using' alias niels at penneman dot org
2012-12-04 21:01 ` [Bug c++/55311] " niels at penneman dot org
2012-12-05  8:33 ` niels at penneman dot org
2012-12-22 16:09 ` dodji at seketeli dot org
2012-12-22 16:11 ` dodji at gcc dot gnu.org
2013-01-07  8:07 ` dodji at gcc dot gnu.org
2013-01-07 11:00 ` dodji at gcc dot gnu.org

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).