public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/34886]  New: Strangeness of name lookup in template function
@ 2008-01-20 16:44 rvovsd at mail dot ru
  2008-01-20 22:21 ` [Bug c++/34886] " pinskia at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: rvovsd at mail dot ru @ 2008-01-20 16:44 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1125 bytes --]

On compiling that code:

--- begin code ---
class Y {};

void f(Y*) { } // line 3. If comment - all ok

template < typename T>
void sel(T* a) { f(a); } //line 6

void f(void*) {}

int main(int argc, char **argv)
{
        sel((void*)0); //line 12
}
--- end code ---

Àppears error:
../main.cpp: In function ‘void sel(T*) [with T = void]’:
../main.cpp:12:   instantiated from here
../main.cpp:6: error: invalid conversion from ‘void*’ to ‘Y*’
../main.cpp:6: error:   initializing argument 1 of ‘void f(Y*)’

If comment line 3, then work.
Also work, if line 3 move after line 6.

If functions f(Y*), f(void*) and sel(T*) placed in different header files, then
arise dependency on order including headers.


-- 
           Summary: Strangeness of name lookup in template function
           Product: gcc
           Version: 4.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rvovsd at mail dot ru
  GCC host triplet: openSuse 10.3


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


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

* [Bug c++/34886] Strangeness of name lookup in template function
  2008-01-20 16:44 [Bug c++/34886] New: Strangeness of name lookup in template function rvovsd at mail dot ru
@ 2008-01-20 22:21 ` pinskia at gcc dot gnu dot org
  2008-01-20 23:23 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-01-20 22:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2008-01-20 21:55 -------
GCC is correct here.  Well partly.  It should reject it no matter what.


-- 


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


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

* [Bug c++/34886] Strangeness of name lookup in template function
  2008-01-20 16:44 [Bug c++/34886] New: Strangeness of name lookup in template function rvovsd at mail dot ru
  2008-01-20 22:21 ` [Bug c++/34886] " pinskia at gcc dot gnu dot org
@ 2008-01-20 23:23 ` pinskia at gcc dot gnu dot org
  2008-01-21 15:15 ` rvovsd at mail dot ru
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-01-20 23:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2008-01-20 22:30 -------
*** Bug 34893 has been marked as a duplicate of this bug. ***


-- 


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


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

* [Bug c++/34886] Strangeness of name lookup in template function
  2008-01-20 16:44 [Bug c++/34886] New: Strangeness of name lookup in template function rvovsd at mail dot ru
  2008-01-20 22:21 ` [Bug c++/34886] " pinskia at gcc dot gnu dot org
  2008-01-20 23:23 ` pinskia at gcc dot gnu dot org
@ 2008-01-21 15:15 ` rvovsd at mail dot ru
  2009-12-08 21:58 ` redi at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rvovsd at mail dot ru @ 2008-01-21 15:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rvovsd at mail dot ru  2008-01-21 14:43 -------
This case is similar to the bug 31047
(http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31047).

There Andrew Pinski wrote (comment 4):
>14.6.4.2/1 says this is invalid code.
>For a function call that depends on a template parameter, if the function is an
>unqualified-id but not a template-id, the candiate functions are found using
>the usual lookup rules (3.4.1, 3.4.2) except that:
>....
>
>Paraphasing since I don't want to type it all in
>* non argument dependent lookup (3.4.1: template definition context
>* argument dependent lookup (3.4.2):  template definition context and template
>instation context

This case is argument dependent lookup, therefore should used both contexts -
definition and instantiation.
Point of instantiation "sel(T* a) with T = void" - after "void f(void*)" and
before "int main()".
Thus should be visible both f(void*) and f(Y*), whether not so?
Why gcc does not see "void f (void *)"?


-- 


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


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

* [Bug c++/34886] Strangeness of name lookup in template function
  2008-01-20 16:44 [Bug c++/34886] New: Strangeness of name lookup in template function rvovsd at mail dot ru
                   ` (2 preceding siblings ...)
  2008-01-21 15:15 ` rvovsd at mail dot ru
@ 2009-12-08 21:58 ` redi at gcc dot gnu dot org
  2009-12-08 22:01 ` pinskia at gcc dot gnu dot org
  2009-12-08 22:03 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu dot org @ 2009-12-08 21:58 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1146 bytes --]



------- Comment #4 from redi at gcc dot gnu dot org  2009-12-08 21:58 -------
In resolving dependent names, names from the following sources are considered:
— Declarations that are visible at the point of de&#64257;nition of the
template.
— Declarations from namespaces associated with the types of the function
arguments both from the instantiation context (14.7.4.1) and from the
de&#64257;nition context.

— If T is a fundamental type, its associated sets of namespaces and classes are
both empty.
— If T is a pointer to U or an array of U, its associated namespaces and
classes are those associated with U.

void* is a pointer to fundamental type so has no associated namespaces, so only
the first source is considered, and only f(T*) is visible at the point of
definition. This is invalid.


-- 

redi at gcc dot gnu dot org changed:

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


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


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

* [Bug c++/34886] Strangeness of name lookup in template function
  2008-01-20 16:44 [Bug c++/34886] New: Strangeness of name lookup in template function rvovsd at mail dot ru
                   ` (3 preceding siblings ...)
  2009-12-08 21:58 ` redi at gcc dot gnu dot org
@ 2009-12-08 22:01 ` pinskia at gcc dot gnu dot org
  2009-12-08 22:03 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-12-08 22:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pinskia at gcc dot gnu dot org  2009-12-08 22:01 -------
Actually ....


-- 

pinskia at gcc dot gnu dot org changed:

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


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


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

* [Bug c++/34886] Strangeness of name lookup in template function
  2008-01-20 16:44 [Bug c++/34886] New: Strangeness of name lookup in template function rvovsd at mail dot ru
                   ` (4 preceding siblings ...)
  2009-12-08 22:01 ` pinskia at gcc dot gnu dot org
@ 2009-12-08 22:03 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-12-08 22:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pinskia at gcc dot gnu dot org  2009-12-08 22:02 -------
> void* is a pointer to fundamental type so has no associated namespaces

Well there is a still open defect report that says this might not be true :).

*** This bug has been marked as a duplicate of 29131 ***


-- 

pinskia at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2009-12-08 22:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-20 16:44 [Bug c++/34886] New: Strangeness of name lookup in template function rvovsd at mail dot ru
2008-01-20 22:21 ` [Bug c++/34886] " pinskia at gcc dot gnu dot org
2008-01-20 23:23 ` pinskia at gcc dot gnu dot org
2008-01-21 15:15 ` rvovsd at mail dot ru
2009-12-08 21:58 ` redi at gcc dot gnu dot org
2009-12-08 22:01 ` pinskia at gcc dot gnu dot org
2009-12-08 22:03 ` pinskia 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).