bugThe FreeType Project - Bugs: bug #50560, Clang warnings when sizeof(void*)...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #50560: Clang warnings when sizeof(void*) != sizeof(unsigned long)

Submitter:  bungeman <bungeman>
Submitted:  Thu 16 Mar 2017 03:19:36 PM UTC
   
 
Severity:  3 - Normal Item Group:  Wishlist
Status:  Fixed Privacy:  Public
Assigned to:  wl Open/Closed:  Closed
Planned Release:  2.8

Mon 03 Apr 2017 04:15:36 PM UTC, comment #5: 

I forgot to run ./configure. I do enjoy quick ccache'd rebuilds.

Alexei Podtelezhnikov <podtelez>
Group Member
Mon 03 Apr 2017 02:07:27 AM UTC, comment #4: 

It is very seriously broken. I still get the same warnings and crash later with

symbol lookup error: ~/freetype2/objs/.libs/libfreetype.so.6: undefined symbol: FT_UINT_TO_POINTER

Alexei Podtelezhnikov <podtelez>
Group Member
Sat 01 Apr 2017 02:28:46 AM UTC, comment #3: 

I get these gcc warnings now:

In file included from /home/apodtele/freetype2/src/truetype/truetype.c:23:0:
/home/apodtele/freetype2/src/truetype/ttgload.c: In function ‘load_truetype_glyph’:
/home/apodtele/freetype2/src/truetype/ttgload.c:1714:26: warning: implicit declaration of function ‘FT_UINT_TO_POINTER’ [-Wimplicit-function-declaration]
                          FT_UINT_TO_POINTER( glyph_index ) ) )
                          ^~~~~~~~~~~~~~~~~~
/home/apodtele/freetype2/src/truetype/ttgload.c:1714:26: warning: passing argument 2 of ‘FT_List_Find’ makes pointer from integer without a cast [-Wint-conversion]
In file included from /home/apodtele/freetype2/src/truetype/ttgload.c:27:0,
                 from /home/apodtele/freetype2/src/truetype/truetype.c:23:
/home/apodtele/freetype2/include/freetype/ftlist.h:94:3: note: expected ‘void *’ but argument is of type ‘int’
   FT_List_Find( FT_List  list,
   ^~~~~~~~~~~~
In file included from /home/apodtele/freetype2/src/truetype/truetype.c:23:0:
/home/apodtele/freetype2/src/truetype/ttgload.c:1723:20: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
         node->data = FT_UINT_TO_POINTER( glyph_index );
                    ^
/home/apodtele/freetype2/src/truetype/ttgload.c:1729:20: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
         node->data = FT_UINT_TO_POINTER( glyph_index );
                    ^


Alexei Podtelezhnikov <podtelez>
Group Member
Sat 18 Mar 2017 04:37:24 PM UTC, comment #2: 

FreeType still assumes C89, which makes it complicated to properly define a 64bit data type without compiler warnings.  Additionally, `uintptr_t' doesn't exist.

Using `sizeof' would exacerbate the problem: Since it is part of the compilation and not the preprocessing step, you had to provide a 64bit data type even if you are not going to use it, e.g.


if ( sizeof(void*) == 8 )
  foo = (void*)(unsigned long long)...
else
  foo = (void*)(unsigned long)...


On the other hand, the only system that uses LLP64 is Windows.  So to me the glib solution seems straightforward, and I have implemented a similar solution.  Please test.

Werner LEMBERG <wl>
Group administrator
Thu 16 Mar 2017 07:43:45 PM UTC, comment #1: 

I just noticed the one mention of GUINT_TO_POINTER in ttgload.c. It appears that glib has to handle this as well, so in glib's glib/glibconfig.h.win32.in it effectively does something like

#ifdef _WIN64
#define GUINT_TO_POINTER(u) ((gpointer) (guint64) (u))
#endif

This seems overly Windows specific, it seems that detecting LLP64 directly with sizeof would be nicer.

bungeman <bungeman>
Thu 16 Mar 2017 03:19:36 PM UTC, original submission:  

When building FreeType with clang for Windows with a target of x64, the following warnings (which are here treated as errors) are produced


> CC obj/third_party/freetype/freetype/truetype.obj
FAILED: obj/third_party/freetype/freetype/truetype.obj
../../third_party/llvm-build/Release+Asserts/bin/clang-cl.exe /nologo /showIncludes /FC @obj/third_party/freetype/freetype/truetype.obj.rsp /c ../../third_party/freetype/src/src/truetype/truetype.c /Foobj/third_party/freetype/freetype/truetype.obj /Fd"obj/third_party/freetype/freetype_c.pdb"
In file included from ../../third_party/freetype/src/src/truetype/truetype.c:25:
C:\src\chromium\src\third_party\freetype\src\src\truetype\ttgload.c(1712,26):  error: cast to 'void *' from smaller integer type 'unsigned long' [-Werror,-Wint-to-void-pointer-cast]
                         (void*)(unsigned long)glyph_index ) )
                         ^
C:\src\chromium\src\third_party\freetype\src\src\truetype\ttgload.c(1721,22):  error: cast to 'void *' from smaller integer type 'unsigned long' [-Werror,-Wint-to-void-pointer-cast]
        node->data = (void*)(unsigned long)glyph_index;
                     ^
C:\src\chromium\src\third_party\freetype\src\src\truetype\ttgload.c(1727,22):  error: cast to 'void *' from smaller integer type 'unsigned long' [-Werror,-Wint-to-void-pointer-cast]
        node->data = (void*)(unsigned long)glyph_index;
                     ^
3 errors generated.


The issue here being that sizeof(void*) == 8 and sizeof(unsigned long) == 4 on this particular platform (LLP64). This seems to be the kind of issue uintptr_t was designed to solve, but not sure if FreeType can use that. Perhaps a FT_UIntPtr typedef could be added to ftconfig.h for this?

bungeman <bungeman>

 

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

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by podtelez (Posted a comment)
  • -email is unavailable- added by wl (Posted a comment)
  • -email is unavailable- added by bungeman (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-03-18 wl StatusNone Fixed
        Assigned toNone wl
        Open/ClosedOpen Closed
        Planned ReleaseNone 2.8

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code