public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/11847] New: std::string as template argument no longer works
@ 2003-08-07 18:33 James dot W dot Mckelvey at jpl dot nasa dot gov
  2003-08-07 18:46 ` [Bug c++/11847] [3.4 regression] reference does not work as template argument any more bangerth at dealii dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: James dot W dot Mckelvey at jpl dot nasa dot gov @ 2003-08-07 18:33 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: std::string as template argument no longer works
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: James dot W dot Mckelvey at jpl dot nasa dot gov
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: sparc-sun-solaris2.7
  GCC host triplet: sparc-sun-solaris2.7
GCC target triplet: sparc-sun-solaris2.7

This error was introduced a few weeks ago. The problem is not in class X, but in
template class Y creating an object of class X using a std::string template
argument. If Y is made non-template, the error disappears.

This code also works on the Compaq cxx and others, so I'm convinced it's a bug.

Reading specs from /mnt/home3/utilities/lib/gcc/sparc-sun-solaris2.7/3.4/specs
Configured with: /mnt/home3/utilities/gcc/configure
--prefix=/mnt/home3/utilities --verbose --with-as=/mnt/home3/utilities/bin/as
--with-ld=/mnt/home3/utilities/bin/ld --with-gnu-as --with-gnu-ld
--disable-multilib --enable-languages=c++
Thread model: posix
gcc version 3.4 20030806 (experimental)
 /mnt/home3/utilities/libexec/gcc/sparc-sun-solaris2.7/3.4/cc1plus -quiet -v
zz.cc -quiet -dumpbase zz.cc -mcpu=v7 -auxbase zz -version -o /tmp/ccy1ULwk.s
#include "..." search starts here:
#include <...> search starts here:
 /mnt/home3/utilities/lib/gcc/sparc-sun-solaris2.7/3.4/../../../../include/c++/3.4
 /mnt/home3/utilities/lib/gcc/sparc-sun-solaris2.7/3.4/../../../../include/c++/3.4/sparc-sun-solaris2.7
 /mnt/home3/utilities/lib/gcc/sparc-sun-solaris2.7/3.4/../../../../include/c++/3.4/backward
 /usr/local/include
 /mnt/home3/utilities/include
 /mnt/home3/utilities/lib/gcc/sparc-sun-solaris2.7/3.4/include
 /mnt/home3/utilities/lib/gcc/sparc-sun-solaris2.7/3.4/../../../../sparc-sun-solaris2.7/include
 /usr/include
End of search list.
GNU C++ version 3.4 20030806 (experimental) (sparc-sun-solaris2.7)
	compiled by GNU C version 3.4 20030806 (experimental).
GGC heuristics: --param ggc-min-expand=65 --param ggc-min-heapsize=65536
zz.cc: In instantiation of `Y<int>':
zz.cc:26:   instantiated from here
zz.cc:18: error: could not convert template argument `&s' to `const 
   std::basic_string<char, std::char_traits<char>, std::allocator<char> >&'

#include <string>


template <const std::string& s>

class X
{
};


extern const std::string s;


template <class T>

class Y
{
    X<s> x;
};


int

main(void)
{
    Y<int> y;

    return 0;
}


const std::string s("who");


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

* [Bug c++/11847] [3.4 regression] reference does not work as template argument any more
  2003-08-07 18:33 [Bug c++/11847] New: std::string as template argument no longer works James dot W dot Mckelvey at jpl dot nasa dot gov
@ 2003-08-07 18:46 ` bangerth at dealii dot org
  2003-08-07 18:48 ` bangerth at dealii dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: bangerth at dealii dot org @ 2003-08-07 18:46 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
  GCC build triplet|sparc-sun-solaris2.7        |
   GCC host triplet|sparc-sun-solaris2.7        |
 GCC target triplet|sparc-sun-solaris2.7        |
   Last reconfirmed|0000-00-00 00:00:00         |2003-08-07 18:46:04
               date|                            |
            Summary|std::string as template     |[3.4 regression] reference
                   |argument no longer works    |does not work as template
                   |                            |argument any more


------- Additional Comments From bangerth at dealii dot org  2003-08-07 18:46 -------
Indeed, I can confirm this on linux as well. Here's a smaller snippet:
----------------------------
extern const int a;

template <const int&> class X {};

template <typename> struct Y {
    X<a> x;
};

template struct Y<int>;
----------------------------

g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc
x.cc: In instantiation of `Y<int>':
x.cc:9:   instantiated from here
x.cc:6: error: could not convert template argument `&a' to `const int&'

This used to work, but doesn't anymore. Since it only happens if Y is
a template class, it seems as if this may have something to do with
two-stage name lookup.

W.


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

* [Bug c++/11847] [3.4 regression] reference does not work as template argument any more
  2003-08-07 18:33 [Bug c++/11847] New: std::string as template argument no longer works James dot W dot Mckelvey at jpl dot nasa dot gov
  2003-08-07 18:46 ` [Bug c++/11847] [3.4 regression] reference does not work as template argument any more bangerth at dealii dot org
@ 2003-08-07 18:48 ` bangerth at dealii dot org
  2003-08-07 18:49 ` pinskia at physics dot uc dot edu
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: bangerth at dealii dot org @ 2003-08-07 18:48 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From bangerth at dealii dot org  2003-08-07 18:48 -------
Just a further clue that this might have something to do with
two-stage name lookup: if I make the variable template
dependent, then the code compiles again. Here's an example:
---------------------------
template <typename T> struct A {
    static const T a;
};

template <const int&> class X {};

template <typename T> struct Y {
    X<A<T>::a> x;
};

template struct Y<int>;
-----------------------------------

W.


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

* [Bug c++/11847] [3.4 regression] reference does not work as template argument any more
  2003-08-07 18:33 [Bug c++/11847] New: std::string as template argument no longer works James dot W dot Mckelvey at jpl dot nasa dot gov
  2003-08-07 18:46 ` [Bug c++/11847] [3.4 regression] reference does not work as template argument any more bangerth at dealii dot org
  2003-08-07 18:48 ` bangerth at dealii dot org
@ 2003-08-07 18:49 ` pinskia at physics dot uc dot edu
  2003-08-11 21:01 ` janis187 at us dot ibm dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-08-07 18:49 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From pinskia at physics dot uc dot edu  2003-08-07 18:49 -------
>From Phil's regression hunter: Search converges between 2003-07-07-trunk (#336) and 2003-
07-08-trunk (#337).


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

* [Bug c++/11847] [3.4 regression] reference does not work as template argument any more
  2003-08-07 18:33 [Bug c++/11847] New: std::string as template argument no longer works James dot W dot Mckelvey at jpl dot nasa dot gov
                   ` (2 preceding siblings ...)
  2003-08-07 18:49 ` pinskia at physics dot uc dot edu
@ 2003-08-11 21:01 ` janis187 at us dot ibm dot com
  2003-08-20 14:36 ` bangerth at dealii dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: janis187 at us dot ibm dot com @ 2003-08-11 21:01 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


janis187 at us dot ibm dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mmitchel at gcc dot gnu dot
                   |                            |org


------- Additional Comments From janis187 at us dot ibm dot com  2003-08-11 21:01 -------
The regression in PR 11847 was introduced or exposed by this patch:

--- gcc/gcc/cp/ChangeLog ---

2003-07-07  Mark Mitchell  <mark@codesourcery.com>

        * cp-tree.h (build_scoped_method_call): Remove.
        (lookup_qualified_name): Remove parameter.
        (tsubst_copy_and_build): Declare.
        [lots more]

The regression hunt took place on i686-pc-linux-gnu using the test
case from comment #1.

This is the same patch that introduced the regression in PR 11834.


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

* [Bug c++/11847] [3.4 regression] reference does not work as template argument any more
  2003-08-07 18:33 [Bug c++/11847] New: std::string as template argument no longer works James dot W dot Mckelvey at jpl dot nasa dot gov
                   ` (3 preceding siblings ...)
  2003-08-11 21:01 ` janis187 at us dot ibm dot com
@ 2003-08-20 14:36 ` bangerth at dealii dot org
  2003-08-23  1:10 ` dhazeghi at yahoo dot com
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: bangerth at dealii dot org @ 2003-08-20 14:36 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From bangerth at dealii dot org  2003-08-20 14:36 -------
May be related to PR 11993. 
W.


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

* [Bug c++/11847] [3.4 regression] reference does not work as template argument any more
  2003-08-07 18:33 [Bug c++/11847] New: std::string as template argument no longer works James dot W dot Mckelvey at jpl dot nasa dot gov
                   ` (4 preceding siblings ...)
  2003-08-20 14:36 ` bangerth at dealii dot org
@ 2003-08-23  1:10 ` dhazeghi at yahoo dot com
  2003-09-02 20:54 ` cvs-commit at gcc dot gnu dot org
  2003-09-02 20:56 ` mmitchel at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: dhazeghi at yahoo dot com @ 2003-08-23  1:10 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


dhazeghi at yahoo dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |critical
           Keywords|                            |rejects-valid
           Priority|P2                          |P1


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

* [Bug c++/11847] [3.4 regression] reference does not work as template argument any more
  2003-08-07 18:33 [Bug c++/11847] New: std::string as template argument no longer works James dot W dot Mckelvey at jpl dot nasa dot gov
                   ` (5 preceding siblings ...)
  2003-08-23  1:10 ` dhazeghi at yahoo dot com
@ 2003-09-02 20:54 ` cvs-commit at gcc dot gnu dot org
  2003-09-02 20:56 ` mmitchel at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2003-09-02 20:54 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From cvs-commit at gcc dot gnu dot org  2003-09-02 20:54 -------
Subject: Bug 11847

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2003-09-02 20:54:08

Modified files:
	gcc/cp         : ChangeLog pt.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/template: class1.C 

Log message:
	PR c++/11847
	* pt.c (convert_nontype_argument): Correct representation of
	REFERENCE_TYPE expressions.
	
	PR c++/11847
	* g++.dg/template/class1.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3637&r2=1.3638
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.770&r2=1.771
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3017&r2=1.3018
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/class1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1


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

* [Bug c++/11847] [3.4 regression] reference does not work as template argument any more
  2003-08-07 18:33 [Bug c++/11847] New: std::string as template argument no longer works James dot W dot Mckelvey at jpl dot nasa dot gov
                   ` (6 preceding siblings ...)
  2003-09-02 20:54 ` cvs-commit at gcc dot gnu dot org
@ 2003-09-02 20:56 ` mmitchel at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2003-09-02 20:56 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


------- Additional Comments From mmitchel at gcc dot gnu dot org  2003-09-02 20:56 -------
Fixed in GCC 3.4.


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

end of thread, other threads:[~2003-09-02 20:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-07 18:33 [Bug c++/11847] New: std::string as template argument no longer works James dot W dot Mckelvey at jpl dot nasa dot gov
2003-08-07 18:46 ` [Bug c++/11847] [3.4 regression] reference does not work as template argument any more bangerth at dealii dot org
2003-08-07 18:48 ` bangerth at dealii dot org
2003-08-07 18:49 ` pinskia at physics dot uc dot edu
2003-08-11 21:01 ` janis187 at us dot ibm dot com
2003-08-20 14:36 ` bangerth at dealii dot org
2003-08-23  1:10 ` dhazeghi at yahoo dot com
2003-09-02 20:54 ` cvs-commit at gcc dot gnu dot org
2003-09-02 20:56 ` mmitchel at gcc dot gnu dot 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).