yet another user bug...
William Morrow
bill.morrow@macsch.com
Fri Jun 18 10:44:00 GMT 1999
Hi,
My name is Bill Morrow. Please test the example below and
see if it is a problem for you in your product. I have encountered
this problem in the redhat delivery 6.0, egcs-1.1.2 release.
I may be reached by email as: bill.morrow@macsch.com.
Additionally, my phone number is: 714-444-4182
Below is an example of the problem uncovered. It relatings to
the expansion of template functions which contain __asm__
__volatile__ blocks. This occurs when standard macros are
applied in the user source. The example can be modified
by commenting out the "template ..." line with // and adding
#define type int
This converts the code to an instance of the template. The
code now compiles without errors. It also can be squashed
by defining __volatile__ as an empty string, although I cannot
say if that is a good idea.
Please reply to acknowledge receiving is message, and if possible
add any known work-around. Perhaps this is just a bug in the user.
-------------------- cut here --------------------
#include <iostream.h>
typedef void *Pointer;
typedef unsigned long xdr_t;
typedef unsigned short int xdr_t_short;
/*
The code that follow is the expansion of:
template <class type>
inline void GET_VAL(Pointer buffer, type& value)
{
value = (type) ntohl( *(xdr_t*)buffer );
}
*/
template <class type>
inline void GET_VAL(Pointer buffer, type& value)
{
value = (type) (__extension__
({ register unsigned int __v;
if (__builtin_constant_p ( *(xdr_t*)buffer ))
__v = (((( *(xdr_t*)buffer ) & 0xff000000) >> 24) |
((( *(xdr_t*)buffer ) & 0x00ff0000) >> 8) |
((( *(xdr_t*)buffer ) & 0x0000ff00) << 8) |
((( *(xdr_t*)buffer ) & 0x000000ff) << 24)) ;
else
__asm__ __volatile__ ( bswap %0" : "=r" (__v) :
"0" ((unsigned int) ( *(xdr_t*)buffer )));
__v; })) ;
}
int main(int ac, char **av)
{
char bfr[128];
int val;
GET_VAL(&bfr[0],val);
cout << val << "\n";
return 0;
}
More information about the Gcc-bugs
mailing list