Closed Bug 923170 Opened 11 years ago Closed 11 years ago

invalid operands of types ‘DrawMode’ and ‘int’ to binary ‘operator!=’

Categories

(Core :: MFBT, defect)

x86_64
Linux
defect
Not set
critical

Tracking

()

RESOLVED FIXED
mozilla27

People

(Reporter: gcp, Assigned: gcp)

References

Details

Attachments

(1 file)

I can no longer make Linux desktop builds on Ubuntu 11.04. This is an entirely standard config, with only "ac_add_options --disable-gstreamer" in the .mozconfig.

gcc version 4.5.2, 64-bit Linux

 9:41.76 /home/morbo/hg/mozilla-central/layout/svg/nsSVGGlyphFrame.cpp: In member function ‘virtual nsresult nsSVGGlyphFrame::PaintSVG(nsRenderingContext*, const nsIntRect*, nsIFrame*)’:
 9:41.77 /home/morbo/hg/mozilla-central/layout/svg/nsSVGGlyphFrame.cpp:425:20: error: invalid operands of types ‘DrawMode’ and ‘int’ to binary ‘operator!=’

It looks like fallout from bug 921753.
Blocks: 921753
IF this impacts developers other than me, then I think the severity needs to be changed from critical to blocker.
Until this is fixed I am no longer producing Linux builds.  Just Windows and Android for now.
I am setting it to blocker.  can be overruled by others.
Severity: critical → blocker
Might not be bad, gives me a non changing thing to do the fair presentation at the summit i guess.
Bill, can you please check if the MOZ_HAVE_CXX11_STRONG_ENUMS macro is #defined inside mfbt/TypedEnum.h?

Also, what's on line 425 on that file for you?  For me, it's:

  if (int(drawMode)) {

I don't see operator!= on that line at all. :/
Flags: needinfo?(wgianopoulos)
1) MOZ_HAVE_CXX11_STRONG_ENUMS is defined (GCC 4.5.2, I put an #error in there to check)
2) The line is indeed the one you show.
Flags: needinfo?(wgianopoulos)
(In reply to Gian-Carlo Pascutto (:gcp) from comment #6)
> 1) MOZ_HAVE_CXX11_STRONG_ENUMS is defined (GCC 4.5.2, I put an #error in
> there to check)
> 2) The line is indeed the one you show.

Same here with GCC 4.5.1.
If I am reading the code correctly, it is impossible for drawMode to be negative here.

Replacing

     if (int(drawMode)) {

with

     if (int(drawMode) > 0) {

appears to avoid the issue.
Reducing severity since there is a workaround.
Severity: blocker → critical
Does anyone understand what's happening from a C++(11) perspective here?
Not really, but I suspect that perhaps since the class definition does not seem to specify 0 as a valid value, perhaps a zero non-zero test does not make sense.
It's a GCC 4.5.x bug. That version is supposed to have most strong enum stuff fixed starting from 4.5.1, which is why we enable them for it, but:

http://ideone.com/Sp2tW1    (compiles and works in gcc 4.8.1)

morbo@ubox:~$ gcc -std=c++0x -o test gcc452.cpp 
gcc452.cpp: In function ‘int main()’:
gcc452.cpp:12:18: error: invalid operands of types ‘DrawMode’ and ‘int’ to binary ‘operator!=’

Based on this, I'll make a patch to bump our support for using strong enums to require at least GCC 4.6.0. We have a fallback in place for older GCC anyway, and that should prevent this issue from reoccurring elsewhere in the code.
(In reply to Gian-Carlo Pascutto (:gcp) from comment #12)
> Based on this, I'll make a patch to bump our support for using strong enums
> to require at least GCC 4.6.0. We have a fallback in place for older GCC
> anyway, and that should prevent this issue from reoccurring elsewhere in the
> code.

Sounds good to me, thanks!  Can you verify that this program compiles properly with gcc 4.6?
Component: Graphics → MFBT
It works with gcc 4.6.3. I think I'd have to actually compile a gcc 4.6.0 to verify it works for that. We can either bump to 4.6.3 directly, or bump to 4.6.0 and see if someone with gcc >=4.6.0<4.6.3 starts complaining in this bug? :)
(In reply to comment #14)
> It works with gcc 4.6.3. I think I'd have to actually compile a gcc 4.6.0 to
> verify it works for that. We can either bump to 4.6.3 directly, or bump to
> 4.6.0 and see if someone with gcc >=4.6.0<4.6.3 starts complaining in this bug?
> :)

I think we should just enable this on gcc 4.6.3.  It's not worth investigating too much into this, IMO.  :-)
Comment on attachment 814237 [details] [diff] [review]
Patch 1. Disable strong enums on older GCC versions.

Review of attachment 814237 [details] [diff] [review]:
-----------------------------------------------------------------

rs=me
Attachment #814237 - Flags: review?(jwalden+bmo) → review+
Comment on attachment 814237 [details] [diff] [review]
Patch 1. Disable strong enums on older GCC versions.

>                 GraphicsFilter filter =
>-                    isDownscale ? aDefaultFilter : GraphicsFilter::FILTER_FAST;
>+                    isDownscale ? aDefaultFilter : (const GraphicsFilter)GraphicsFilter::FILTER_FAST;
>                 aPattern->SetFilter(filter);

This part seems unrelated to the version-bump.  Did some compiler choke on this patch without this?

(Just pushing back slightly because the C-style cast is sadmaking... const_cast<> would be nicer & get us more type-safety, if we really do need a cast there.)
>Did some compiler choke on this patch without this?

The fallback path for <4.6.3 has a type mismatch without this cast. You wouldn't have seen this before unless you were compiling m-c with gcc 4.4. It got exposed because more people will be using the fallback now.
https://hg.mozilla.org/mozilla-central/rev/657aa2568bc2
Assignee: nobody → gpascutto
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla27
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: