This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Problem with use of anonymous types
- From: Andrew Pinski <pinskia at physics dot uc dot edu>
- To: "Julian Cummings" <cummings at cacr dot caltech dot edu>
- Cc: <gcc-bugs at gcc dot gnu dot org>
- Date: Fri, 6 May 2005 20:09:03 -0400
- Subject: Re: Problem with use of anonymous types
- References: <200505070006.j4706eQn012724@mail.cacr.caltech.edu>
On May 6, 2005, at 8:09 PM, Julian Cummings wrote:
People are reporting trouble compiling blitz with gcc-4.0.0, and the
compiler errors are resulting from the use of unnamed enums. A simple
code
illustrates the problem:
struct nullType {};
template <typename T> inline T operator+(const T& a, nullType) {
return a;
}
enum named { namedA = 1, namedB = 2 };
enum { unnamedA = 2, unnamedB = 4 };
struct bar {
enum { namedC = namedA + namedB,
unnamedC = unnamedA + unnamedB };
};
int main() {
}
The gcc compiler complains about trying to add unnamedA and unnamedB.
Apparently it gets confused by the presence of the operator+ overload
for
the empty struct nullType. I don't see why the compiler would think
that
the anonymous enumerators unnamedA or unnamedB would match with type
nullType. Enumerators are supposed to default to integers when used in
arithmetic operations such as operator+. Everything compiles fine
when the
operator+ overload is not present. The code compiles as is under
gcc-3.4.
What gives?
This is a bug in your code. See PR 19404 and PR 20589.
-- Pinski