bugThe FreeType Project - Bugs: bug #25133, incompatible type declarations by...

 
 

bug #25133: incompatible type declarations by FT_USE_MODULE

Submitted by:  None
Submitted on:  Sat 20 Dec 2008 07:56:14 AM UTC  
 
Severity: 3 - NormalItem Group: None
Status: FixedPrivacy: Public
Assigned to: Werner LEMBERG <wl>Open/Closed: Closed
Planned Release: 2.3.8

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Sun 21 Dec 2008 10:30:57 AM UTC, comment #1:

Applied, thanks!

Werner LEMBERG <wl>
Project AdministratorIn charge of this item.
Sat 20 Dec 2008 07:56:14 AM UTC, original submission:

FT_USE_MODULE declares things as:

extern const FT_Module_Class

(or similar for C++). However, the actual types of the variables being declared are often different, e.g., FT_Driver_ClassRec or FT_Renderer_Class. (Some are, indeed, FT_Module_Class.)

This works with most C compilers (since those structs begin with an FT_Module_Class struct), but technically it's undefined behavior.

To quote the ISO/IEC 9899:TC2 final committee draft, section 6.2.7 paragraph 2:

All declarations that refer to the same object or function shall have compatible type; otherwise, the behavior is undefined.

(And these are not compatible types. I read the relevant sections of the standard -- pity me! -- and also consulted with a coworker who's more knowledgeable about the C and C++ standards than I am.)

Most C compilers don't reject (or even detect!) code which has this issue, but the GCC LTO development branch compiler does. (It outputs the types of the objects while generating .o files, along with a bunch of other information, then compares them when doing the final link-time code generation pass.)

The solution is to declare these variables as having the correct types. Easy, if a bit tedious.

I've attached a patch which does this, which was coded against CVS sources checked out this evening.

I've tested it only by compiling with that compiler + with 'stock' GCC (built with GNU make), so some of the changes in the patch are untested. But IMO they're obviously-correct.

Anonymous

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #17099:  freetype2_decl.patch added by None (17KiB - text/x-patch - patch to fix issue.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by wl (Posted a comment)
  • -unavailable- added by cgd_ ((I was the initial submitter, I just created an account))
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements 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
    Sun 21 Dec 2008 10:30:57 AM UTCwlStatusNone=>Fixed
      Assigned toNone=>wl
      Open/ClosedOpen=>Closed
      Planned ReleaseNone=>2.3.8
    Sat 20 Dec 2008 07:59:47 AM UTCcgd_Carbon-Copy-=>Added cgd_
    Sat 20 Dec 2008 07:56:14 AM UTCNoneAttached File-=>Added freetype2_decl.patch, #17099

    Back to the top


    Powered by Savane 3.1-cleanup1