egcs bug report
Vadim Gouterman
vadimg@cadabratech.com
Thu Jun 24 14:39:00 GMT 1999
Short Description:
egcs does not report taking an address of a bitfield as an error
and generates incorrect code
Software version:
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
OS Version:
SunOS 5.5.1 Generic sun4u sparc SUNW,Ultra-1
Command line used to invoke compiler:
/opt/gnu/egcs-1.1.2/bin/gcc egcspr.cc -lstdc++
Full description:
Take a look at the testcase, line 13. The code requests to take
an address of bitfield variable "i". This should not be allowed,
but compiler does not complain and generates incorrect code.
Value of the variable is not passed from the function. The testcase
clearly indicates that.
Testcase:
The testcase file "egcspr.cc" is attached to this mail.
Please contact me if you need any additional information.
--
Vadim Gouterman
Sr. Member of Scientific Staff
mailto:vadimg@cadabradesign.com
Cadabra Design Automation Inc.
Phone (613) 226-7046
http://www.cadabradesign.com
#include <iostream.h>
class A {
enum type {
X, Y, Z, XY, BC, ZBC
};
type i:16;
static void get(type &p);
public:
A():i(0){}
void print() {
get(i);
cout << "Instead we get: " << (int)i << endl;
}
};
void A::get( A::type &p )
{
int x = 5;
p = (A::type)x;
cout << "It should be: " << (int)p << endl;
}
int main()
{
A a;
cout << "===================Problem report====================\n"
<< "No warning for taking address of bitfield" << endl;
a.print();
return 0;
}
More information about the Gcc-bugs
mailing list