[Bug c++/31986] New: conversion-type-id should match in both contexts
andrew dot stubbs at st dot com
gcc-bugzilla@gcc.gnu.org
Fri May 18 13:38:00 GMT 2007
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
More information about the Gcc-bugs
mailing list