https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67650

Jan Hubicka <hubicka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at redhat dot com

--- Comment #8 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
I think this is a bug in testcase and/or C++ FE.  I get:
main.cpp:33:8: warning: �void AN<OC, RC>::rp() [with OC = LR<I, IE, ((const
char*)(& ET))>::LLC; RC = BLKC]� used but never defined

/tmp/ccT1Jzgh.o:main.cpp:function main: error: undefined reference to 'operator
new(unsigned long)'
/tmp/ccT1Jzgh.o:main.cpp:function LK<LR<I, IE, &ET>::LL>::rb(): error:
undefined reference to 'AN<LR<I, IE, &ET>::LLC, BLKC>::rp()'

_ZN2ANIN2LRI1I2IEXadL_ZL2ETEEE3LLCE4BLKCE2rpEv is virtual function that is not
defined:

_ZN2ANIN2LRI1I2IEXadL_ZL2ETEEE3LLCE4BLKCE2rpEv/504 (void AN<OC, RC>::rp() [with
OC = LR<I, IE, ((const char*)(& ET))>::LLC; RC = BLKC]) @0x7ffff5aa2000
  Type: function
  Visibility: external public virtual
  References: 
  Referring: 
  First run: 0
  Function flags:
  Called by: _ZN2REI2ELIN2LRI1I2IEXadL_ZL2ETEEE3LLCEEE2axEv/485 (1.00 per call)
(can throw external) 
  Calls: 

and is used as:
_ZN2LKIN2LRI1I2IEXadL_ZL2ETEEE2LLEE2rbEv/484 (void LK<T>::rb() [with T = LR<I,
IE, ((const char*)(& ET))>::LL]) @0x7ffff5a4fa10
  Type: function definition analyzed                                            
  Visibility: prevailing_def_ironly virtual                                     
  Address is taken.                                                             
  References:                                                                   
  Referring: _ZTV2LKIN2LRI1I2IEXadL_ZL2ETEEE2LLEE/441 (addr)                    
  Availability: available                                                       
  First run: 0                                                                  
  Function flags: body                                                          
  Called by:                                                                    
  Calls: _ZN2ANIN2LRI1I2IEXadL_ZL2ETEEE3LLCE4BLKCE2rpEv/504 (1.00 per call)
(can throw external)


Now with -fno-devirtualize we get:
/484 (void LK<T>::rb() [with T = LR<I, IE, ((const char*)(& ET))>::LL])
@0x7ffff5a4fa10
  Type: function definition analyzed                                            
  Visibility: prevailing_def_ironly virtual                                     
  Address is taken.                                                             
  References:                                                                   
  Referring: _ZTV2LKIN2LRI1I2IEXadL_ZL2ETEEE2LLEE/441 (addr)                    
  Availability: available                                                       
  First run: 0                                                                  
  Function flags: body                                                          
  Called by:                                                                    
  Calls:                                                                        
   Polymorphic indirect call of type struct RE token:0(1.00 per call) (can
throw external)
    nothing known                                                               

So it is simply devirtualization of:
;; Function void LK<T>::rb() [with T = LR<I, IE, ((const char*)(& ET))>::LL]
(_ZN2LKIN2LRI1I2IEXadL_ZL2ETEEE2LLEE2rbEv, funcdef_no=1102, decl_uid=24008,
cgraph_uid=438, symbol_order=484)

void LK<T>::rb() [with T = LR<I, IE, ((const char*)(& ET))>::LL] (struct LK *
const this)
{                                                                               
  struct RE * _1;                                                               
  int (*__vtbl_ptr_type) () * _3;                                               
  int (*__vtbl_ptr_type) () _4;                                                 

  <bb 2>:                                                                       
  _1 = &MEM[(struct LL *)0B].D.25771.D.25733;                                   
  _3 = MEM[(struct RE *)0B]._vptr.RE;                                           
  _4 = *_3;                                                                     
  OBJ_TYPE_REF(_4;(struct RE)_1->0) (_1);                                       
  return;                                                                       

}                                                                               
to
;; Function void LK<T>::rb() [with T = LR<I, IE, ((const char*)(& ET))>::LL]
(_ZN2LKIN2LRI1I2IEXadL_ZL2ETEEE2LLEE2rbEv, funcdef_no=1102, decl_uid=24008,
cgraph_uid=438, symbol_order=484)

void LK<T>::rb() [with T = LR<I, IE, ((const char*)(& ET))>::LL] (struct LK *
const this)
{                                                                               
  struct RE * _1;                                                               

  <bb 2>:                                                                       
  _1 = &MEM[(struct LL *)0B].D.25771.D.25733;                                   
  AN<LR<I, IE, ((const char*)(& ET))>::LLC, BLKC>::rp (_1);                     
  return;                                                                       

}                                                                               

which seems legit to me. Generally you need to provide definitions for virtual
functions you declare.

Jason, can you please take a look if that is really a non-bug?

Reply via email to