GLContextProviderEGL.cpp fails to compile on mingw-w64

RESOLVED FIXED in mozilla17

Status

()

Core
Graphics
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: Jacek Caban, Assigned: Jacek Caban)

Tracking

Trunk
mozilla17
x86_64
Windows 7
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

5 years ago
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.
Attachment #646557 - Flags: review?(snorp)
(Assignee)

Comment 1

5 years ago
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...
(Assignee)

Comment 3

5 years ago
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?
(Assignee)

Comment 6

5 years ago
Thanks for the review. I will commit it myself.
(Assignee)

Comment 7

5 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/111ee5107308
https://hg.mozilla.org/mozilla-central/rev/111ee5107308
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla17
You need to log in before you can comment on or make changes to this bug.