public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/61987] New: Name Resolution within a Template
@ 2014-08-01  9:34 gaoyuanming at hotmail dot com
  2014-08-01  9:36 ` [Bug c++/61987] " gaoyuanming at hotmail dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: gaoyuanming at hotmail dot com @ 2014-08-01  9:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61987

            Bug ID: 61987
           Summary: Name Resolution within a Template
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gaoyuanming at hotmail dot com

Created attachment 33222
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33222&action=edit
Assembly code

I compiled the piece of code:

#include <stdlib.h>

int foo(double d) { return static_cast<int>(d); }

template <typename T>
class Test
{
public:
        Test(int id, T const & value) : m_id(id), m_value(value) {}

        void change()
        {
                m_value = foo(m_id);
        }

        void change(int seed)
        {
                m_id = foo(m_value) * seed;
        }

        T value() const { return m_value; }
private:
        int m_id;
        T   m_value;
};

int foo(int n) { return n; }

int main()
{
    Test<int> t(10, 20);
    t.change();
    t.change(2);

    Test<unsigned long> tul(10, 30);
    tul.change();
    tul.change(3);

    return 0;
}

and found that the function void Test<int>::change(int) calls int foo(double)
to implement it. It is a bug.


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

end of thread, other threads:[~2014-08-07 15:57 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-01  9:34 [Bug c++/61987] New: Name Resolution within a Template gaoyuanming at hotmail dot com
2014-08-01  9:36 ` [Bug c++/61987] " gaoyuanming at hotmail dot com
2014-08-01  9:46 ` pinskia at gcc dot gnu.org
2014-08-01 10:00 ` gaoyuanming at hotmail dot com
2014-08-01 10:06 ` pinskia at gcc dot gnu.org
2014-08-01 10:28 ` redi at gcc dot gnu.org
2014-08-01 11:25 ` gaoyuanming at hotmail dot com
2014-08-01 11:27 ` gaoyuanming at hotmail dot com
2014-08-01 11:32 ` redi at gcc dot gnu.org
2014-08-01 18:39 ` daniel.kruegler at googlemail dot com
2014-08-07 15:57 ` redi 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).