This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/31986] New: conversion-type-id should match in both contexts
- From: "andrew dot stubbs at st dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 May 2007 13:38:29 -0000
- Subject: [Bug c++/31986] New: conversion-type-id should match in both contexts
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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