pr27650 - dllimport of virtual methods broken.

Mark Mitchell mark@codesourcery.com
Thu Sep 14 00:14:00 GMT 2006


Carlos O'Donell wrote:
> Is any of you able to give some comments on pr27650
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27650
> 
> In particular I am interested in an opinion of Danny's fix.
> 
> http://gcc.gnu.org/ml/gcc-patches/2006-05/msg01504.html
> 
> I definately don't know enough about attributes and dllimport to
> comment. The fix works, but is it correct?

I think the idea of the patch is correct: virtual functions shouldn't be 
marked dllimport because you need their addresses to be constants so 
that they can go in virtual tables.

However, I think that the winnt.c change (which has already been checked 
in) shouldn't be necessary.  It only makes sense if we set 
DECL_DLLIMPORT_P at one point, and then set it back to zero, indicating 
that we don't want to allow the function to be dllimport'ed.  But, in 
that case, I don't think dllimport should still be on the 
DECL_ATTRIBUTES list.  So, it seems like a band-aid.

The cp/decl2.c change also seems less than ideal.  The key invariant is 
that virtual functions can't be dllimport'd.  So, I think we should mark 
them that way when they're declared, perhaps in grokfndecl or in 
cp_finish_decl.

It could be that I'm missing something, though; Danny might want to 
debate my conclusions.

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713



More information about the Gcc mailing list