buggperf - Bugs: bug #37071, plain inlines (with external...

 
 

bug #37071: plain inlines (with external linkage) cause havoc when mixed with internal linkage inlines

Submitted by:  Sebastian Freundt <hroptatyr>
Submitted on:  Fri Aug 10 12:50:03 2012  
Votes:  1  
 
Category: Generated codeSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: Bruno Haible <haible>
Open/Closed: Closed

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sat Nov 26 17:45:38 2016, comment #3:

Thanks for the report.

The lookup function must not carry the inline specifier; this is a consequence of ISO C 99 6.7.4.

> in order for lookup function to have the same linkage as hashing one


This would have the effect of making the lookup function 'static' in C++ - which solves the inline problem but does not work for users who want to call the function from a different compilation unit.

So, I've removed the inline specifier on the lookup function.

Bruno Haible <haible>
Project AdministratorIn charge of this item.
Wed Nov 23 23:14:59 2016, comment #2:

Citing http://www.devsuperpage.com/search/Articles.aspx?G=5&ArtID=186075 :

"6.7.4 Function specifiers
Syntax
function-specifier:
inline

Constraints
Function specifiers shall be used only in the declaration of an
identifier for a function. An inline definition of a function
with external linkage shall not contain a definition of a
modifiable object with static storage duration, and shall not
^^^^^^^^^^^^^
contain a reference to an identifier with internal linkage."

Bruno Haible <haible>
Project AdministratorIn charge of this item.
Wed Dec 24 04:48:12 2014, comment #1:

Well, the main question is why it was made with internal linkage in first place. If it's just a link-time optimization then it can be safely thrown away. Also, in order for lookup function to have the same linkage as hashing one
should be added to attributes. In this way not only the original bug is fixed, but related compilation problem is resolved as well.

Sergii Strelkovskyi <loozer>
Fri Aug 10 12:50:03 2012, original submission:

The emitted code

#ifdef _GNUC_
__inline
#else
#ifdef __cplusplus
inline
#endif
#endif
static unsigned int
__tid_hash (register const char *str, register unsigned int len)
{
...
}

has internal linkage (as per the static keyword).

In contrast, a few lines down the road:

#ifdef _GNUC_
__inline
#if defined _GNUC_STDC_INLINE_ || defined _GNUC_GNU_INLINE_
_attribute_ ((_gnu_inline_))
#endif
#endif
const struct tws_xml_tag_s *
__tiddify (register const char *str, register unsigned int len)
{
...
register int key = __tid_hash (str, len);
...
}

there's a reference from a function with external linkage (as per the plain inline) to a function with internal linkage.

This results in a warning:

../../src/proto-twsxml-tag.gperf(28): warning #1173: an entity with internal linkage cannot be referenced within an inline function with external linkage

Suggested fix:
Both functions (maybe optionally) should have internal linkage.

Sebastian Freundt <hroptatyr>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by haible (Posted a comment)
  • -unavailable- added by loozer (Voted in favor of this item)
  • -unavailable- added by loozer (Posted a comment)
  • -unavailable- added by hroptatyr (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 1 encouragement so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat Nov 26 17:45:38 2016haibleStatusConfirmed=>Fixed
      Assigned toNone=>haible
      Open/ClosedOpen=>Closed
    Sat Nov 26 02:30:21 2016haibleStatusNone=>Confirmed
    Thu Nov 24 00:08:35 2016haibleCategoryNone=>Generated code
    Wed Dec 24 04:49:46 2014loozerCarbon-Copy-=>Added loozer

    Back to the top


    Powered by Savane 3.1-cleanup