public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug bootstrap/93962] bootstrap fails with gcc/value-prof.c:268:28 : error: format '%lld' expects argument of type 'long long int', but argument 3 hastype 'int'
       [not found] <bug-93962-4@http.gcc.gnu.org/bugzilla/>
@ 2020-03-10 12:37 ` ebotcazou at gcc dot gnu.org
  2020-03-10 13:33 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2020-03-10 12:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93962

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ebotcazou at gcc dot gnu.org

--- Comment #10 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
There is another abs at line 746 which causes a bootstrap failure on Solaris
11:

/homes/botcazou/gcc-head/src/gcc/value-prof.c: In function 'bool
get_nth_most_common_value(gimple*, const char*, histogram_value, gcov_type*,
gcov_type*, gcov_type*, unsigned int)':
/homes/botcazou/gcc-head/src/gcc/value-prof.c:746:53: error: call of overloaded
'abs(gcov_type&)' is ambiguous
   gcov_type read_all = abs (hist->hvalue.counters[0]);
                                                     ^
/homes/botcazou/gcc-head/src/gcc/value-prof.c:746:53: note: candidates are:
In file included from /usr/include/stdlib.h:11:0,
                 from /homes/botcazou/gcc-head/src/gcc/system.h:258,
                 from /homes/botcazou/gcc-head/src/gcc/value-prof.c:21:
/usr/include/iso/stdlib_iso.h:154:23: note: long int std::abs(long int)
  inline long   abs(long _l) { return labs(_l); }
                       ^
/usr/include/iso/stdlib_iso.h:108:12: note: int std::abs(int)
 extern int abs(int);
            ^
gmake[3]: *** [value-prof.o] Error 1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug bootstrap/93962] bootstrap fails with gcc/value-prof.c:268:28 : error: format '%lld' expects argument of type 'long long int', but argument 3 hastype 'int'
       [not found] <bug-93962-4@http.gcc.gnu.org/bugzilla/>
  2020-03-10 12:37 ` [Bug bootstrap/93962] bootstrap fails with gcc/value-prof.c:268:28 : error: format '%lld' expects argument of type 'long long int', but argument 3 hastype 'int' ebotcazou at gcc dot gnu.org
@ 2020-03-10 13:33 ` jakub at gcc dot gnu.org
  2020-03-10 13:52 ` gerald at pfeifer dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-03-10 13:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93962

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marxin at gcc dot gnu.org

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I think even the using of std::abs in the #c8 case isn't correct, because the
std::abs (long long); overload has been only added in C++11 and we in GCC 10
still do support C++98 compilers.
So I think we instead should use abs_hwi (or absu_hwi, depending on if the most
negative value can appear or not) instead of std::abs or abs in value-prof.c.
So e.g.
--- gcc/value-prof.c    2020-03-05 07:58:02.693135980 +0100
+++ gcc/value-prof.c    2020-03-10 14:32:10.723649888 +0100
@@ -266,7 +266,7 @@ dump_histogram_value (FILE *dump_file, h
          if (hist->hvalue.counters)
            {
              fprintf (dump_file, " all: %" PRId64 "%s, values: ",
-                      std::abs ((int64_t) hist->hvalue.counters[0]),
+                      absu_hwi (hist->hvalue.counters[0]),
                       hist->hvalue.counters[0] < 0
                       ? " (values missing)": "");
              for (unsigned i = 0; i < GCOV_TOPN_VALUES; i++)
@@ -743,7 +743,7 @@ get_nth_most_common_value (gimple *stmt,
   *count = 0;
   *value = 0;

-  gcov_type read_all = abs (hist->hvalue.counters[0]);
+  gcov_type read_all = absu_hwi (hist->hvalue.counters[0]);

   gcov_type v = hist->hvalue.counters[2 * n + 1];
   gcov_type c = hist->hvalue.counters[2 * n + 2];

or with s/absu/abs/.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug bootstrap/93962] bootstrap fails with gcc/value-prof.c:268:28 : error: format '%lld' expects argument of type 'long long int', but argument 3 hastype 'int'
       [not found] <bug-93962-4@http.gcc.gnu.org/bugzilla/>
  2020-03-10 12:37 ` [Bug bootstrap/93962] bootstrap fails with gcc/value-prof.c:268:28 : error: format '%lld' expects argument of type 'long long int', but argument 3 hastype 'int' ebotcazou at gcc dot gnu.org
  2020-03-10 13:33 ` jakub at gcc dot gnu.org
@ 2020-03-10 13:52 ` gerald at pfeifer dot com
  2020-03-10 14:35 ` marxin at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: gerald at pfeifer dot com @ 2020-03-10 13:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93962

--- Comment #12 from Gerald Pfeifer <gerald at pfeifer dot com> ---
Created attachment 48011
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48011&action=edit
Preprocessed value-prof.c for the failure case on FreeBSD 11/i386

(I've been struggling to create the preprocessed source files, but keep
working on it. This is the first one - for the failure case.)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug bootstrap/93962] bootstrap fails with gcc/value-prof.c:268:28 : error: format '%lld' expects argument of type 'long long int', but argument 3 hastype 'int'
       [not found] <bug-93962-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2020-03-10 13:52 ` gerald at pfeifer dot com
@ 2020-03-10 14:35 ` marxin at gcc dot gnu.org
  2020-03-10 14:42 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-03-10 14:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93962

--- Comment #13 from Martin Liška <marxin at gcc dot gnu.org> ---
> So I think we instead should use abs_hwi (or absu_hwi, depending on if the
> most negative value can appear or not) instead of std::abs or abs in
> value-prof.c.

No, the counter can never be INT64_MIN.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug bootstrap/93962] bootstrap fails with gcc/value-prof.c:268:28 : error: format '%lld' expects argument of type 'long long int', but argument 3 hastype 'int'
       [not found] <bug-93962-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2020-03-10 14:35 ` marxin at gcc dot gnu.org
@ 2020-03-10 14:42 ` jakub at gcc dot gnu.org
  2020-03-11  8:37 ` jakub at gcc dot gnu.org
  2020-03-11 16:11 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-03-10 14:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93962

--- Comment #14 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Ok, I'll test a patch with abs_hwi in both spots then.  There will be an
assertion in there that it is not INT64_MIN.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug bootstrap/93962] bootstrap fails with gcc/value-prof.c:268:28 : error: format '%lld' expects argument of type 'long long int', but argument 3 hastype 'int'
       [not found] <bug-93962-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2020-03-10 14:42 ` jakub at gcc dot gnu.org
@ 2020-03-11  8:37 ` jakub at gcc dot gnu.org
  2020-03-11 16:11 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-03-11  8:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93962

--- Comment #15 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
commit r10-7122-g60342fdbfb0630243d2b85d2ca45204ded990b17
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Mar 11 09:34:59 2020 +0100

    value-prof: Fix abs uses in value-prof.c [PR93962]

    Jeff has recently fixed dump_histogram_value to use std::abs instead of
abs,
    because on FreeBSD apparently the ::abs isn't overloaded and only has
    int abs (int);
    Seems on Solaris /usr/include/iso/stdlib_iso.h abs has:
    int abs (int);
    long abs (long);
    overloads but already not
    long long abs (long long);
    and there is another abs use in get_nth_most_common_value, also on int64_t.
    The long long std::abs (long long); overload is there only in C++11 and we
    in GCC10 still support C++98.

    Martin has said that a counter should never be INT64_MIN, so IMHO it is
    better to use abs_hwi which will assert that.

    2020-03-11  Jakub Jelinek  <jakub@redhat.com>

            PR bootstrap/93962
            * value-prof.c (dump_histogram_value): Use abs_hwi instead of
            std::abs.
            (get_nth_most_common_value): Use abs_hwi instead of abs.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug bootstrap/93962] bootstrap fails with gcc/value-prof.c:268:28 : error: format '%lld' expects argument of type 'long long int', but argument 3 hastype 'int'
       [not found] <bug-93962-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2020-03-11  8:37 ` jakub at gcc dot gnu.org
@ 2020-03-11 16:11 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-03-11 16:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93962

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #16 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-03-11 16:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-93962-4@http.gcc.gnu.org/bugzilla/>
2020-03-10 12:37 ` [Bug bootstrap/93962] bootstrap fails with gcc/value-prof.c:268:28 : error: format '%lld' expects argument of type 'long long int', but argument 3 hastype 'int' ebotcazou at gcc dot gnu.org
2020-03-10 13:33 ` jakub at gcc dot gnu.org
2020-03-10 13:52 ` gerald at pfeifer dot com
2020-03-10 14:35 ` marxin at gcc dot gnu.org
2020-03-10 14:42 ` jakub at gcc dot gnu.org
2020-03-11  8:37 ` jakub at gcc dot gnu.org
2020-03-11 16:11 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).