This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Audit of some older C++ bug reports (c++/6626)


http://gcc.gnu.org/ml/gcc-bugs/2002-10/msg00795.html

  c++/6626 (__attribute__ doen not works with function pointers)
      I have the feeling that this may have been fixed in the meantime. 
      What do the Windows maintainers say -- Christopher, DJ?


The testcase in the PR still raises error in C++.  However, the placement of 
__attribute__((__stdcall__)) in that code is a bit strange.  IMO, it shouldn't
compile on C either.

FWIW, the testcase also fails on MSVC++ after changing the
__attribute__((stdcall)) to the equivalent MS extension __stdcall.
 
Placement of attribute is significant for declarations of function pointers .
This 

   __attribute__((__stdcall__)) void (*local)(int *x);

doesn't make sense and is the cause of the failure.

The usual syntax is 

 void (__attribute__((__stdcall__)) *local)(int *x);

 because the attribute applies to the function calling convention not the
return type. The following code compiles fine with C and C++:

=== begin ===

void __attribute__((__stdcall__))  test(int *x)
{
  *x = 1;
}

int main(void)
{
  void (__attribute__((__stdcall__)) *local)(int *x);

  local = (void (__attribute__((__stdcall__)) *)(int*)) test;

  local = test;

}

==== end ====

Danny




http://careers.yahoo.com.au - Yahoo! Careers
- 1,000's of jobs waiting online for you!


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]