public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51951] New: Template function dependent name resolution fails
@ 2012-01-22 20:40 basil at list dot ru
  2012-01-22 20:56 ` [Bug c++/51951] " redi at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: basil at list dot ru @ 2012-01-22 20:40 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51951
           Summary: Template function dependent name resolution fails
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: basil@list.ru


Created attachment 26417
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26417
test


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

* [Bug c++/51951] Template function dependent name resolution fails
  2012-01-22 20:40 [Bug c++/51951] New: Template function dependent name resolution fails basil at list dot ru
@ 2012-01-22 20:56 ` redi at gcc dot gnu.org
  2012-01-22 20:57 ` basil at list dot ru
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2012-01-22 20:56 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|major                       |normal

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-01-22 20:35:21 UTC ---
t.cc: In instantiation of ‘void readSingle(Option<T>&) [with T = int]’:
t.cc:19:15:   required from here
t.cc:10:5: error: ‘readFromStream’ was not declared in this scope, and no
declarations were found by argument-dependent lookup at the point of
instantiation [-fpermissive]
t.cc:14:6: note: ‘template<class T> void readFromStream(T&)’ declared here,
later in the translation unit

seems correct to me, what's the bug?


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

* [Bug c++/51951] Template function dependent name resolution fails
  2012-01-22 20:40 [Bug c++/51951] New: Template function dependent name resolution fails basil at list dot ru
  2012-01-22 20:56 ` [Bug c++/51951] " redi at gcc dot gnu.org
@ 2012-01-22 20:57 ` basil at list dot ru
  2012-01-22 21:18 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: basil at list dot ru @ 2012-01-22 20:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Vasily Sukhanov <basil at list dot ru> 2012-01-22 20:39:41 UTC ---
Compilation of attached code fails despite it is accepted by previous GCC
versions.

  1 template <class T>
  2 class Option {
  3 public:
  4   bool m_bValid;
  5   T m_t;
  6 };
  7 
  8 template<class T>
  9 void readSingle(Option<T>& opt) {
 10     readFromStream(opt.m_bValid);
 11 }
 12 
 13 template <class T>
 14 void readFromStream(T& t) {  }
 15 
 16 int main()
 17 {
 18   Option<int> o;
 19   readSingle(o);
 20 }


template_test.cpp: In instantiation of ‘void readSingle(Option<T>&) [with T =
int]’:
template_test.cpp:19:15:   required from here
template_test.cpp:10:5: error: ‘readFromStream’ was not declared in this scope,
and no declarations were found by argument-dependent lookup at the point of
instantiation [-fpermissive]
template_test.cpp:14:6: note: ‘template<class T> void readFromStream(T&)’
declared here, later in the translation unit

I think that instantiation point of readSingle<int> is line 19. readFromStream
in line 10 is dependent on template parameter. Therefore compiler should
perform lookup in context of template instantiation (14.6.4.2). readFromStream
was defined by this point.  
I'm on revision 183301.


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

* [Bug c++/51951] Template function dependent name resolution fails
  2012-01-22 20:40 [Bug c++/51951] New: Template function dependent name resolution fails basil at list dot ru
  2012-01-22 20:56 ` [Bug c++/51951] " redi at gcc dot gnu.org
  2012-01-22 20:57 ` basil at list dot ru
@ 2012-01-22 21:18 ` pinskia at gcc dot gnu.org
  2012-01-22 23:55 ` redi at gcc dot gnu.org
  2012-01-23  1:19 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-01-22 21:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-01-22 20:55:33 UTC ---
bool has no namespace associated with it as it is a foundational type.  There
is a DR against the C++ standard about this issue.


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

* [Bug c++/51951] Template function dependent name resolution fails
  2012-01-22 20:40 [Bug c++/51951] New: Template function dependent name resolution fails basil at list dot ru
                   ` (2 preceding siblings ...)
  2012-01-22 21:18 ` pinskia at gcc dot gnu.org
@ 2012-01-22 23:55 ` redi at gcc dot gnu.org
  2012-01-23  1:19 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2012-01-22 23:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-01-22 23:39:05 UTC ---
(In reply to comment #2)
> Compilation of attached code fails despite it is accepted by previous GCC
> versions.

That's not a bug, GCC has been fixed to conform to the standard.  The Comeau
and LLVM online compilers give the same result.


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

* [Bug c++/51951] Template function dependent name resolution fails
  2012-01-22 20:40 [Bug c++/51951] New: Template function dependent name resolution fails basil at list dot ru
                   ` (3 preceding siblings ...)
  2012-01-22 23:55 ` redi at gcc dot gnu.org
@ 2012-01-23  1:19 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2012-01-23  1:19 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-01-22 23:48:56 UTC ---
14.6.4 Dependent name resolution [temp.dep.res]
-1- In resolving dependent names, names from the following sources are
considered:
— Declarations that are visible at the point of definition of the template.
— Declarations from namespaces associated with the types of the function
arguments both from the instantiation context (14.6.4.1) and from the definition
context.

readFromStream is a dependent name, no declaration is visible at the point of
definition of readSingle, bool has no associated namespaces so no declarations
from associated namespaces are considered, so the name is not found.  The code
is invalid.


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

end of thread, other threads:[~2012-01-22 23:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-22 20:40 [Bug c++/51951] New: Template function dependent name resolution fails basil at list dot ru
2012-01-22 20:56 ` [Bug c++/51951] " redi at gcc dot gnu.org
2012-01-22 20:57 ` basil at list dot ru
2012-01-22 21:18 ` pinskia at gcc dot gnu.org
2012-01-22 23:55 ` redi at gcc dot gnu.org
2012-01-23  1:19 ` 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).