Bug 162302 - [GTK] webkit-gtk-2.14.0 build failure of ScrollbarThemeGtk with libc++
Summary: [GTK] webkit-gtk-2.14.0 build failure of ScrollbarThemeGtk with libc++
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: WebKit Nightly Build
Hardware: Mac OS X 10.11
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-20 10:43 PDT by Jeremy Huddleston Sequoia
Modified: 2016-09-21 06:24 PDT (History)
3 users (show)

See Also:


Attachments
0002-GTK-Fix-build-failure-of-ScrollbarThemeGtk-with-libc (2.34 KB, patch)
2016-09-20 10:52 PDT, Jeremy Huddleston Sequoia
no flags Details | Formatted Diff | Diff
0002-GTK-Fix-build-failure-of-ScrollbarThemeGtk-with-libc (2.31 KB, patch)
2016-09-20 11:10 PDT, Jeremy Huddleston Sequoia
cgarcia: review-
mcatanzaro: commit-queue-
Details | Formatted Diff | Diff
0002-GTK-Fix-build-failure-of-ScrollbarThemeGtk-with-libc (1.63 KB, patch)
2016-09-21 00:36 PDT, Jeremy Huddleston Sequoia
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremy Huddleston Sequoia 2016-09-20 10:43:10 PDT
2.14.0 fails to build with the following error using clang+libc++ on darwin:

webkitgtk-2.14.0/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp:547:35: error: call to 'abs' is ambiguous
                contentsRect.move(std::abs(rect.width() - preferredSize.width()), 0);
                                  ^~~~~~~~
../include/c++/v1/cmath:664:1: note: candidate function
abs(float __lcpp_x) _NOEXCEPT {return fabsf(__lcpp_x);}
^
../include/c++/v1/cmath:668:1: note: candidate function
abs(double __lcpp_x) _NOEXCEPT {return fabs(__lcpp_x);}
^
../include/c++/v1/cmath:672:1: note: candidate function
abs(long double __lcpp_x) _NOEXCEPT {return fabsl(__lcpp_x);}
^
webkitgtk-2.14.0/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp:552:34: error: call to 'abs' is ambiguous
            contentsRect.move(0, std::abs(rect.height() - preferredSize.height()));
                                 ^~~~~~~~
../include/c++/v1/cmath:664:1: note: candidate function
abs(float __lcpp_x) _NOEXCEPT {return fabsf(__lcpp_x);}
^
../include/c++/v1/cmath:668:1: note: candidate function
abs(double __lcpp_x) _NOEXCEPT {return fabs(__lcpp_x);}
^
../include/c++/v1/cmath:672:1: note: candidate function
abs(long double __lcpp_x) _NOEXCEPT {return fabsl(__lcpp_x);}
^
2 errors generated.

Casting the call site to (double) addresses the issue.
Comment 1 Jeremy Huddleston Sequoia 2016-09-20 10:52:06 PDT
Created attachment 289382 [details]
0002-GTK-Fix-build-failure-of-ScrollbarThemeGtk-with-libc
Comment 2 WebKit Commit Bot 2016-09-20 10:54:29 PDT
Attachment 289382 [details] did not pass style-queue:


ERROR: Source/WebCore/ChangeLog:8:  You should remove the 'No new tests' and either add and list tests, or explain why no new tests were possible.  [changelog/nonewtests] [5]
Total errors found: 1 in 2 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Jeremy Huddleston Sequoia 2016-09-20 11:10:45 PDT
Created attachment 289387 [details]
0002-GTK-Fix-build-failure-of-ScrollbarThemeGtk-with-libc
Comment 4 Alex Christensen 2016-09-20 11:50:05 PDT
Comment on attachment 289387 [details]
0002-GTK-Fix-build-failure-of-ScrollbarThemeGtk-with-libc

If such a cast is needed, please use static_cast instead of a c-style cast.
Comment 5 Michael Catanzaro 2016-09-20 12:29:04 PDT
Comment on attachment 289387 [details]
0002-GTK-Fix-build-failure-of-ScrollbarThemeGtk-with-libc

Yes, as Alex said.
Comment 6 Carlos Garcia Campos 2016-09-20 23:13:30 PDT
Comment on attachment 289387 [details]
0002-GTK-Fix-build-failure-of-ScrollbarThemeGtk-with-libc

View in context: https://bugs.webkit.org/attachment.cgi?id=289387&action=review

> Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp:547
> -                contentsRect.move(std::abs(rect.width() - preferredSize.width()), 0);
> +                contentsRect.move(std::abs((double)(rect.width() - preferredSize.width())), 0);

I think it would be cleaner to cast the result of abs, because both rect and preferredSize are ints, instead of using the abs overload for floats with integers, we could use the int one and cast the result. Another way to disambiguate this could be using std::fabs, adn then we don't need any ugly cast.
Comment 7 Jeremy Huddleston Sequoia 2016-09-20 23:39:26 PDT
Oh, I wonder if it's not picking up the integral std::abs() because of a missing #include <cstdlib>.  Giving that a try.
Comment 8 Jeremy Huddleston Sequoia 2016-09-21 00:36:43 PDT
Created attachment 289435 [details]
0002-GTK-Fix-build-failure-of-ScrollbarThemeGtk-with-libc

Yep, changed patch to include <cstdlib>, so the integer versions are available.
Comment 9 WebKit Commit Bot 2016-09-21 02:51:05 PDT
Comment on attachment 289435 [details]
0002-GTK-Fix-build-failure-of-ScrollbarThemeGtk-with-libc

Clearing flags on attachment: 289435

Committed r206205: <http://trac.webkit.org/changeset/206205>
Comment 10 WebKit Commit Bot 2016-09-21 02:51:09 PDT
All reviewed patches have been landed.  Closing bug.
Comment 11 Michael Catanzaro 2016-09-21 06:24:10 PDT
(In reply to comment #7)
> Oh, I wonder if it's not picking up the integral std::abs() because of a
> missing #include <cstdlib>.  Giving that a try.

Ugh, let's remember to check for this whenever we see a patch that changes std::abs. It's not the first time this has been an issue, but I forgot.