Closed Bug 778129 Opened 12 years ago Closed 12 years ago

GLContextProviderEGL.cpp fails to compile on mingw-w64

Categories

(Core :: Graphics, defect)

x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla17

People

(Reporter: jacek, Assigned: jacek)

Details

Attachments

(1 file)

Attached patch fix v1.0Splinter Review
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.
Attachment #646557 - Flags: review?(snorp)
James, ping
(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...
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 on attachment 646557 [details] [diff] [review]
fix v1.0

Alright, I'm convinced :)
Attachment #646557 - Flags: review?(snorp) → review+
Do you need me to check this in for you?
Thanks for the review. I will commit it myself.
https://hg.mozilla.org/mozilla-central/rev/111ee5107308
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla17
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: