Last Comment Bug 778129 - GLContextProviderEGL.cpp fails to compile on mingw-w64
: GLContextProviderEGL.cpp fails to compile on mingw-w64
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: Graphics (show other bugs)
: Trunk
: x86_64 Windows 7
-- normal (vote)
: mozilla17
Assigned To: Jacek Caban
:
: Milan Sreckovic [:milan]
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-07-27 06:44 PDT by Jacek Caban
Modified: 2012-08-02 19:09 PDT (History)
3 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
fix v1.0 (999 bytes, patch)
2012-07-27 06:44 PDT, Jacek Caban
snorp: review+
Details | Diff | Splinter Review

Description User image Jacek Caban 2012-07-27 06:44:27 PDT
Created attachment 646557 [details] [diff] [review]
fix v1.0

Because on win64 sizeof(long) != sizeof(void*), GCC is strict about preventing pointer to any int with smaller size to avoid common mistakes. Thus, the cast must be made more carefully.
Comment 1 User image Jacek Caban 2012-08-01 01:19:21 PDT
James, ping
Comment 2 User image James Willcox (:snorp) (jwillcox@mozilla.com) 2012-08-01 07:05:51 PDT
(In reply to Jacek Caban from comment #0)
> Created attachment 646557 [details] [diff] [review]
> fix v1.0
> 
> Because on win64 sizeof(long) != sizeof(void*), GCC is strict about
> preventing pointer to any int with smaller size to avoid common mistakes.
> Thus, the cast must be made more carefully.

Sorry for the late reply. Slipped off my radar somehow.

Anyway, I think the sizeof(long) != sizeof(void*) thing is true elsewhere but the cast works. This cast to uintptr_t looks incorrect to me, considering that's not what GLuint is. Can you paste the error you get? Surely it's just a warning?

Bringing in some other folks who probably have an opinion...
Comment 3 User image Jacek Caban 2012-08-01 07:23:43 PDT
Yes, it's an error and it looks like this:

mozilla-central/gfx/gl/GLContextProviderEGL.cpp:938:34: error: cast from ‘void*’ to ‘GLuint {aka unsigned int}’ loses precision [-fpermissive]

I've fixed a few such cases in the codebase, and it's nothing really special here... The trick is to always cast pointers to integers of the same size. Although GLUint is not the same as uintptr_t, it's not a problem, because there will be an implicit cast. So instead of one cast that both changes pointer to integer and loses precision, we have an explicit cast that does safe pointer to integer cast and then implicit cast (in assignment expression) that loses integer precision.
Comment 4 User image James Willcox (:snorp) (jwillcox@mozilla.com) 2012-08-01 07:25:05 PDT
Comment on attachment 646557 [details] [diff] [review]
fix v1.0

Alright, I'm convinced :)
Comment 5 User image James Willcox (:snorp) (jwillcox@mozilla.com) 2012-08-01 07:26:02 PDT
Do you need me to check this in for you?
Comment 6 User image Jacek Caban 2012-08-01 07:27:02 PDT
Thanks for the review. I will commit it myself.
Comment 8 User image Ryan VanderMeulen [:RyanVM] 2012-08-02 19:09:43 PDT
https://hg.mozilla.org/mozilla-central/rev/111ee5107308

Note You need to log in before you can comment on or make changes to this bug.