public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/31986]  New: conversion-type-id should match in both contexts
@ 2007-05-18 13:38 andrew dot stubbs at st dot com
  2007-05-18 13:54 ` [Bug c++/31986] " andrew dot stubbs at st dot com
  0 siblings, 1 reply; 3+ messages in thread
From: andrew dot stubbs at st dot com @ 2007-05-18 13:38 UTC (permalink / raw)
  To: gcc-bugs

The following C++ program should not compile:

#include <stdio.h>

class C
{
public:
  typedef float T;
  operator T() {return 1;};
  operator int() {return 2;};
} c;

int
main ()
{
  typedef int T;
  printf ("%d\n", (T) c.operator T());  // invalid
  printf ("%d\n", T(c));
  printf ("%d\n", (T)c);
}

The C++ standard, clause 3.4.5, paragraph 7, says that the `T' should refer to
the same type in both `C' and `main'.

The output from this program, with GCC 4.1.1, is "1 2 2" (i.e. a `float' and
two `int's). This shows that the name `T' is significant here.


-- 
           Summary: conversion-type-id should match in both contexts
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: andrew dot stubbs at st dot com


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


^ permalink raw reply	[flat|nested] 3+ messages in thread
[parent not found: <bug-31986-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2012-01-28  2:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-18 13:38 [Bug c++/31986] New: conversion-type-id should match in both contexts andrew dot stubbs at st dot com
2007-05-18 13:54 ` [Bug c++/31986] " andrew dot stubbs at st dot com
     [not found] <bug-31986-4@http.gcc.gnu.org/bugzilla/>
2012-01-28  3:07 ` pinskia 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).