public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug build/29798] New: symtab.c doesn't compile with 32-bit GCC 12
@ 2022-11-17 14:54 ro at gcc dot gnu.org
  2022-11-17 14:57 ` [Bug build/29798] " ro at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: ro at gcc dot gnu.org @ 2022-11-17 14:54 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29798

            Bug ID: 29798
           Summary: symtab.c doesn't compile with 32-bit GCC 12
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: build
          Assignee: unassigned at sourceware dot org
          Reporter: ro at gcc dot gnu.org
  Target Milestone: 13.1

Compiling symtab.c with a 32-bit GCC 12 (12.2.0 on Solaris 11.4 in my case)
fails like this:

/vol/src/gnu/gdb/hg/master/local/gdb/symtab.c: In member function
‘std::vector<symbol_search> global_symbol_searcher::search() const’:
/vol/src/gnu/gdb/hg/master/local/gdb/symtab.c:4961:44: error: ‘std::sprintf’
may write a terminating nul past the end of the destination
[-Werror=format-overflow=]
 4961 |               sprintf (tmp, "operator%.*s%s", fix, " ", opname);
      |                                            ^
/vol/src/gnu/gdb/hg/master/local/gdb/symtab.c:4961:23: note: ‘std::sprintf’
output between 9 and 2147483648 bytes into a destination of size 2147483647
 4961 |               sprintf (tmp, "operator%.*s%s", fix, " ", opname);
      |               ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I'm uncertain how best to address this.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug build/29798] symtab.c doesn't compile with 32-bit GCC 12
  2022-11-17 14:54 [Bug build/29798] New: symtab.c doesn't compile with 32-bit GCC 12 ro at gcc dot gnu.org
@ 2022-11-17 14:57 ` ro at gcc dot gnu.org
  2022-11-17 16:22 ` simon.marchi at polymtl dot ca
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: ro at gcc dot gnu.org @ 2022-11-17 14:57 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29798

--- Comment #1 from Rainer Orth <ro at gcc dot gnu.org> ---
Oh, I forgot: this isn't a Solaris issue at all.  Building for
i686-pc-linux-gnu
shows the same error.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug build/29798] symtab.c doesn't compile with 32-bit GCC 12
  2022-11-17 14:54 [Bug build/29798] New: symtab.c doesn't compile with 32-bit GCC 12 ro at gcc dot gnu.org
  2022-11-17 14:57 ` [Bug build/29798] " ro at gcc dot gnu.org
@ 2022-11-17 16:22 ` simon.marchi at polymtl dot ca
  2022-11-18 15:48 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: simon.marchi at polymtl dot ca @ 2022-11-17 16:22 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29798

Simon Marchi <simon.marchi at polymtl dot ca> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simon.marchi at polymtl dot ca

--- Comment #2 from Simon Marchi <simon.marchi at polymtl dot ca> ---
(In reply to Rainer Orth from comment #0)
> Compiling symtab.c with a 32-bit GCC 12 (12.2.0 on Solaris 11.4 in my case)
> fails like this:
> 
> /vol/src/gnu/gdb/hg/master/local/gdb/symtab.c: In member function
> ‘std::vector<symbol_search> global_symbol_searcher::search() const’:
> /vol/src/gnu/gdb/hg/master/local/gdb/symtab.c:4961:44: error: ‘std::sprintf’
> may write a terminating nul past the end of the destination
> [-Werror=format-overflow=]
>  4961 |               sprintf (tmp, "operator%.*s%s", fix, " ", opname);
>       |                                            ^
> /vol/src/gnu/gdb/hg/master/local/gdb/symtab.c:4961:23: note: ‘std::sprintf’
> output between 9 and 2147483648 bytes into a destination of size 2147483647
>  4961 |               sprintf (tmp, "operator%.*s%s", fix, " ", opname);
>       |               ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> I'm uncertain how best to address this.

Use string_printf to make it an std::string.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug build/29798] symtab.c doesn't compile with 32-bit GCC 12
  2022-11-17 14:54 [Bug build/29798] New: symtab.c doesn't compile with 32-bit GCC 12 ro at gcc dot gnu.org
  2022-11-17 14:57 ` [Bug build/29798] " ro at gcc dot gnu.org
  2022-11-17 16:22 ` simon.marchi at polymtl dot ca
@ 2022-11-18 15:48 ` cvs-commit at gcc dot gnu.org
  2022-11-18 16:01 ` simark at simark dot ca
  2022-11-20 13:53 ` cvs-commit at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-11-18 15:48 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29798

--- Comment #3 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Simon Marchi <simark@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9c48a8e6f43965b8d530159e5dbb2fc9d6083646

commit 9c48a8e6f43965b8d530159e5dbb2fc9d6083646
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date:   Fri Nov 18 10:48:03 2022 -0500

    gdb: fix symtab.c build on 32 bit targets

    When building on Ubuntu 22.04, gcc 12, x86-64 with -m32 and -O2, I get:

          CXX    symtab.o
        /home/smarchi/src/binutils-gdb/gdb/symtab.c: In member function
ââ¬Ëstd::vector<symbol_search> global_symbol_searcher::search()
constââ¬â¢:
        /home/smarchi/src/binutils-gdb/gdb/symtab.c:4961:44: error:
ââ¬Ë__builtin___sprintf_chkââ¬â¢ may write a terminating nul past the end
of the destination [-Werror=format-overflow=]
         4961 |               sprintf (tmp, "operator%.*s%s", fix, " ",
opname);
              |                                            ^
        In file included from /usr/include/stdio.h:894,
                         from ../gnulib/import/stdio.h:43,
                         from
/home/smarchi/src/binutils-gdb/gdb/../gdbsupport/common-defs.h:86,
                         from /home/smarchi/src/binutils-gdb/gdb/defs.h:28,
                         from /home/smarchi/src/binutils-gdb/gdb/symtab.c:20:
        In function ââ¬Ëint sprintf(char*, const char*, ...)ââ¬â¢,
            inlined from ââ¬Ëstd::vector<symbol_search>
global_symbol_searcher::search() constââ¬â¢ at
/home/smarchi/src/binutils-gdb/gdb/symtab.c:4961:16:
        /usr/include/i386-linux-gnu/bits/stdio2.h:38:34: note:
ââ¬Ë__builtin___sprintf_chkââ¬â¢ output between 9 and 2147483648 bytes
into a destination of size 2147483647
           38 |   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
              |          ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           39 |                                   __glibc_objsize (__s), __fmt,
              |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           40 |                                   __va_arg_pack ());
              |                                   ~~~~~~~~~~~~~~~~~

    PR build/29798 shows a similar error message but on Solaris.

    Work around that by using string_printf.  It is a good thing to get rid
    of the alloca anyway.

    Change-Id: Ifbac11fee3062ad7f134d596b4e2229dc5d166f9
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29798

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug build/29798] symtab.c doesn't compile with 32-bit GCC 12
  2022-11-17 14:54 [Bug build/29798] New: symtab.c doesn't compile with 32-bit GCC 12 ro at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2022-11-18 15:48 ` cvs-commit at gcc dot gnu.org
@ 2022-11-18 16:01 ` simark at simark dot ca
  2022-11-20 13:53 ` cvs-commit at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: simark at simark dot ca @ 2022-11-18 16:01 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29798

Simon Marchi <simark at simark dot ca> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simark at simark dot ca
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #4 from Simon Marchi <simark at simark dot ca> ---
Fixed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug build/29798] symtab.c doesn't compile with 32-bit GCC 12
  2022-11-17 14:54 [Bug build/29798] New: symtab.c doesn't compile with 32-bit GCC 12 ro at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2022-11-18 16:01 ` simark at simark dot ca
@ 2022-11-20 13:53 ` cvs-commit at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-11-20 13:53 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29798

--- Comment #5 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Rainer Orth <ro@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f1a8d786c37bbe40d0bc2fec618d0e875d043811

commit f1a8d786c37bbe40d0bc2fec618d0e875d043811
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Sun Nov 20 14:52:09 2022 +0100

    Fix sol-thread.c compilation on 32-bit Solaris

    sol-thread.c fails to compile on 32-bit Solaris: there are several
    instances of

    In file included from
/vol/src/gnu/gdb/hg/master/local/gdb/../gdbsupport/common-defs.h:203,
                     from /vol/src/gnu/gdb/hg/master/local/gdb/defs.h:28,
                     from /vol/src/gnu/gdb/hg/master/local/gdb/sol-thread.c:51:
    /vol/src/gnu/gdb/hg/master/local/gdb/sol-thread.c: In member function
âvirtual void sol_thread_target::resume(ptid_t, int, gdb_signal)â:
    /vol/src/gnu/gdb/hg/master/local/gdb/sol-thread.c:416:20: error: format
â%ldâ expects argument of type âlong intâ, but argument 2 has type
âULONGESTâ {aka âlong long unsigned intâ} [-Werror=format=]
      416 |         warning (_("Specified thread %ld seems to have
terminated"),
          |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /vol/src/gnu/gdb/hg/master/local/gdb/../gdbsupport/gdb_locale.h:28:29:
    note: in definition of macro â_â
       28 | # define _(String) gettext (String)
          |                             ^~~~~~
    /vol/src/gnu/gdb/hg/master/local/gdb/sol-thread.c:416:40: note: format
    string is defined here
      416 |         warning (_("Specified thread %ld seems to have
terminated"),
          |                                      ~~^
          |                                        |
          |                                        long int
          |                                      %lld

    Fixed by using pulongest () instead.

    Tested on i386-pc-solaris2.11, amd64-pc-solaris2.11,
    sparc-sun-solaris2.11, and sparcv9-sun-solaris2.11 (together with
    Simon's patch for PR build/29798).

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

end of thread, other threads:[~2022-11-20 13:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-17 14:54 [Bug build/29798] New: symtab.c doesn't compile with 32-bit GCC 12 ro at gcc dot gnu.org
2022-11-17 14:57 ` [Bug build/29798] " ro at gcc dot gnu.org
2022-11-17 16:22 ` simon.marchi at polymtl dot ca
2022-11-18 15:48 ` cvs-commit at gcc dot gnu.org
2022-11-18 16:01 ` simark at simark dot ca
2022-11-20 13:53 ` cvs-commit 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).