public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/24680]  New: [accept invalid] Invalid template code accepted
@ 2005-11-05  0:44 ppluzhnikov at charter dot net
  2005-11-05  0:55 ` [Bug c++/24680] " pinskia at gcc dot gnu dot org
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: ppluzhnikov at charter dot net @ 2005-11-05  0:44 UTC (permalink / raw)
  To: gcc-bugs

$ cat junk.cc
template <typename T>
struct List
{
    struct D { int size; };
    D *d;

    List &fill(const T &t, int size = -1);
};

template <typename T>
List<T> &List<T>::fill(const T &t, int size)
{
    resize(size ? 1 : d->size);
    return *this;
}

$ /usr/local/gcc-4.1-20051001/bin/g++ -c junk.cc
# silently accepted

Replacing "resize(size...);" with "resize(1);" correctly rejects the bogus
source (g++ versions 3.4 and above):

junk.cc: In member function 'List<T>& List<T>::fill(const T&, int)':
junk.cc:13: error: there are no arguments to 'resize' that depend on a template
parameter, so a declaration of 'resize' must be available
junk.cc:13: error: (if you use '-fpermissive', G++ will accept your code, but
allowing the use of an undeclared name is deprecated)


-- 
           Summary: [accept invalid] Invalid template code accepted
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ppluzhnikov at charter dot net
 GCC build triplet: x86_64-redhat-linux
  GCC host triplet: x86_64-redhat-linux
GCC target triplet: x86_64-redhat-linux


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


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

end of thread, other threads:[~2005-11-07 17:39 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-05  0:44 [Bug c++/24680] New: [accept invalid] Invalid template code accepted ppluzhnikov at charter dot net
2005-11-05  0:55 ` [Bug c++/24680] " pinskia at gcc dot gnu dot org
2005-11-05  1:14 ` rnewman at compubrite dot com
2005-11-05  1:17 ` ppluzhnikov at charter dot net
2005-11-05  1:21 ` rnewman at compubrite dot com
2005-11-05  1:24 ` pinskia at gcc dot gnu dot org
2005-11-05  1:29 ` rnewman at compubrite dot com
2005-11-05  1:35 ` pinskia at gcc dot gnu dot org
2005-11-05  1:55 ` rnewman at compubrite dot com
2005-11-05  1:58 ` pinskia at gcc dot gnu dot org
2005-11-05  2:18 ` pinskia at gcc dot gnu dot org
2005-11-05  2:19 ` pinskia at gcc dot gnu dot org
2005-11-05  2:23 ` pinskia at gcc dot gnu dot org
2005-11-05  2:33 ` pinskia at gcc dot gnu dot org
2005-11-05  2:49 ` pinskia at gcc dot gnu dot org
2005-11-05  3:10 ` pinskia at gcc dot gnu dot org
2005-11-05  3:18 ` pinskia at gcc dot gnu dot org
2005-11-07 17:39 ` rnewman at compubrite 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).