public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/42292]  New: gcc should reject code violating the two-phase look-up rules (related to bug 42291)
@ 2009-12-05  0:02 wan at google dot com
  2009-12-05  0:06 ` [Bug c++/42292] fundamental type have an associated namespace? pinskia at gcc dot gnu dot org
  2009-12-05  0:10 ` pinskia at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: wan at google dot com @ 2009-12-05  0:02 UTC (permalink / raw)
  To: gcc-bugs

The following code shouldn't compile; yet gcc accepts it:

template <typename T>
int Foo() {
 return Bar(T());
}

int x = Foo<bool>();  // This shouldn't compile.

int Bar(bool x) {
 return 0;
}

The problem is that when Foo<bool>() is instantiated, the compiler should
search for Bar() only at the template definition site, not at the point of
instantiation, since bool is not a class type and ADL doesn't apply.

Similarly, this shouldn't compile either, but gcc also accepts it:

template <typename T>
int Foo() {
 return Bar(T());
}

int Bar(bool x) {
 return 0;
}

int x = Foo<bool>();  // This shouldn't compile.

Note that both clang and Comeau reject the code correctly.

This is related to bug 42291 - I don't know if they are caused by exactly the
same thing though.


-- 
           Summary: gcc should reject code violating the two-phase look-up
                    rules (related to bug 42291)
           Product: gcc
           Version: 4.2.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: wan at google dot com


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


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

* [Bug c++/42292] fundamental type have an associated namespace?
  2009-12-05  0:02 [Bug c++/42292] New: gcc should reject code violating the two-phase look-up rules (related to bug 42291) wan at google dot com
@ 2009-12-05  0:06 ` pinskia at gcc dot gnu dot org
  2009-12-05  0:10 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-12-05  0:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2009-12-05 00:05 -------
There are two different issues here, only is the place where we instantiated
foo<bool> is wrong but the second issue is even weird and I think there is a
C++ defect report about it (do fundamental types have associated namespace).


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|gcc should reject code      |fundamental type have an
                   |violating the two-phase     |associated namespace?
                   |look-up rules (related to   |
                   |bug 42291)                  |


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


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

* [Bug c++/42292] fundamental type have an associated namespace?
  2009-12-05  0:02 [Bug c++/42292] New: gcc should reject code violating the two-phase look-up rules (related to bug 42291) wan at google dot com
  2009-12-05  0:06 ` [Bug c++/42292] fundamental type have an associated namespace? pinskia at gcc dot gnu dot org
@ 2009-12-05  0:10 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-12-05  0:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2009-12-05 00:10 -------
The wrong place is PR 16635.

>ADL doesn't apply.
Or does it?  See C++ defect report 225.

The fundamental type issue is PR 29131 (and DR 225 for the C++ defect report).


Closing as a dup of bug 16635.

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


-- 

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=42292


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

end of thread, other threads:[~2009-12-05  0:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-05  0:02 [Bug c++/42292] New: gcc should reject code violating the two-phase look-up rules (related to bug 42291) wan at google dot com
2009-12-05  0:06 ` [Bug c++/42292] fundamental type have an associated namespace? pinskia at gcc dot gnu dot org
2009-12-05  0:10 ` 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).