bug-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

g++ volatile keyword bug in template instantiation?


From: Marat Ruvinov
Subject: g++ volatile keyword bug in template instantiation?
Date: Wed, 14 Feb 2001 14:38:34 -0500

Hello,

The simple template instantiation of a method using macro FD_SET defined
on my Red Hat Linux 6.2 via /usr/include/sys/select.h is choking on the
keyword 'volatile'.
Below is the file and error output.....

////////////////////////////////////////////////////  file: b.C
#include <sys/select.h>

template <class T>
class A
{
public:
void foo();
};

template <class T>
void A<T>::foo()
{
  fd_set f;
  FD_ZERO(&f);   // line 15
}

main()
{
  A<int> obj;
  obj.foo();   // instantiation necessary
}

> g++ b.C
b.C: In method `void A<int>::foo<int>()':
b.C:21:   instantiated from here
b.C:15: `volatile' undeclared (first use this function)
b.C:15: (Each undeclared identifier is reported only once
b.C:15: for each function it appears in.)
b.C:15: warning:  qualifier ignored on asm



FD_SET is defined as via select.h as:
"
do {  int __d0, __d1; __asm__ __volatile__ ("cld; rep;
stosl" : "=c" (__d0), "=D" (__d1)      : "a" (0), "0"
(sizeof (__fd_set)       / sizeof (__fd_mask)), "1" (& ((
&f   )->__fds_bits) [0])     : "memory");    } while (0)  ;
"

Please note that the FD_SET macro compiles outside a template definition
as in :
#include <sys/select.h>
main()
{
   fd_set f;
   FD_ZERO(&f);
}


The compiler version is :
> g++ -v
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)


Is this a compiler bug ? since it fails only upon template
instantiation....

Thanks,

- Marat



--








"I have made this letter longer than usual, because I lack the time to
make it short"
    - B. Pascal





reply via email to

[Prev in Thread] Current Thread [Next in Thread]