public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/98444] New: [10 Regression] compile error with -ftracer and -Werror=format-overflow
@ 2020-12-25 15:29 drfiemost at email dot it
  2020-12-27 20:05 ` [Bug tree-optimization/98444] " msebor at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: drfiemost at email dot it @ 2020-12-25 15:29 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98444
           Summary: [10 Regression] compile error with -ftracer and
                    -Werror=format-overflow
           Product: gcc
           Version: 10.2.1
               URL: https://github.com/elogind/elogind/issues/189
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: drfiemost at email dot it
  Target Milestone: ---

Created attachment 49843
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49843&action=edit
Preprocessed source

I get the following error compiling the attached code with gcc-10 (gcc version
10.2.1 20201205):

$ gcc -O2 -ftracer -Werror=format-overflow -c pam_elogind.i 
../src/login/pam_elogind.c: In function ‘export_legacy_dbus_address’:
../src/login/pam_elogind.c:315:13: error: ‘%s’ directive argument is null
[-Werror=format-overflow=]
cc1: some warnings being treated as errors


According to upstream [1] the variable is asserted before calling the function
so it will never be null.
The code compiles fine with gcc-9 and even with gcc-10 when removing the
-ftracer flag.
I can't tell if it's a regression in gcc-10, just a false positive or what so
I'm reporting it here.

[1] https://github.com/elogind/elogind/issues/189

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

* [Bug tree-optimization/98444] [10 Regression] compile error with -ftracer and -Werror=format-overflow
  2020-12-25 15:29 [Bug tree-optimization/98444] New: [10 Regression] compile error with -ftracer and -Werror=format-overflow drfiemost at email dot it
@ 2020-12-27 20:05 ` msebor at gcc dot gnu.org
  2021-01-14  8:13 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-12-27 20:05 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msebor at gcc dot gnu.org
   Last reconfirmed|                            |2020-12-27
             Status|UNCONFIRMED                 |NEW
      Known to work|                            |11.0, 9.3.0
     Ever confirmed|0                           |1
      Known to fail|                            |10.2.0

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
The warning is based on the IL below where the %s argument is null, so it's
working correctly.  It doesn't consider the complex control flow (bb2 -> b10 ->
bb5) from which it could deduce the asprintf call with the null pointer is only
reachable conditionally to issue a more nuanced message, but that wouldn't
prevent it, only make its conditional nature more apparent (all warnings are
conditional on the function they're in being called).  The assertion that the
runtime pointer is nonnull is in export_legacy_dbus_address's caller,
configure_runtime_directory, 
which is inlined into its caller, and has no effect on the code in
export_legacy_dbus_address.  Adding something like:

  if (!runtime) __builtin_unreachable ();

just before the problematic call to asprintf() avoids the warning.

In GCC 9 or on trunk (GCC 11), jump threading doesn't introduce the the invalid
call so the warning doesn't trigger.  So I can confirm this regression for GCC
10 but I don't expect to be able to do anything about it there.  Longer term,
we're aware of these warnings for synthesized code but we're still looking for
a solution to avoid them.

export_legacy_dbus_address (struct pam_handle_t * handle, const char * runtime)
{
  ...
  <bb 2> [local count: 397250656]:
  t = 0B;
  if (runtime_22(D) != 0B)
    goto <bb 3>; [94.50%]
  else
    goto <bb 10>; [5.50%]

  <bb 3> [local count: 382684072]:
  _65 = strlen (runtime_22(D));
  _n__16 = _65 + 5;
  if (_n__16 > 4194304)
    goto <bb 4>; [10.58%]
  else
    goto <bb 11>; [89.42%]

  <bb 4> [local count: 39725066]:
  log_assert_failed_realm (0, "sizeof(char)*_n_ <= ALLOCA_MAX",
&"../src/login/pam_elogind.c"[3], 311, &__PRETTY_FUNCTION__);

  <bb 5> [local count: 7591956]:
  _10 = asprintf (&t, "unix:path=%s/bus", 0B);   <<< warning here
  if (_10 < 0)
    goto <bb 6>; [26.36%]
  else
    goto <bb 7>; [73.64%]

  ...
  <bb 10> [local count: 21848788]:
  _29 = __builtin_alloca (1);
  *_29 = 0;
  _appendees_ ={v} {CLOBBER};
  _9 = access (_29, 0);
  if (_9 < 0)
    goto <bb 9>; [42.09%]
  else
    goto <bb 5>; [57.91%]

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

* [Bug tree-optimization/98444] [10 Regression] compile error with -ftracer and -Werror=format-overflow
  2020-12-25 15:29 [Bug tree-optimization/98444] New: [10 Regression] compile error with -ftracer and -Werror=format-overflow drfiemost at email dot it
  2020-12-27 20:05 ` [Bug tree-optimization/98444] " msebor at gcc dot gnu.org
@ 2021-01-14  8:13 ` rguenth at gcc dot gnu.org
  2021-04-08 12:02 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-01-14  8:13 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |10.3

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

* [Bug tree-optimization/98444] [10 Regression] compile error with -ftracer and -Werror=format-overflow
  2020-12-25 15:29 [Bug tree-optimization/98444] New: [10 Regression] compile error with -ftracer and -Werror=format-overflow drfiemost at email dot it
  2020-12-27 20:05 ` [Bug tree-optimization/98444] " msebor at gcc dot gnu.org
  2021-01-14  8:13 ` rguenth at gcc dot gnu.org
@ 2021-04-08 12:02 ` rguenth at gcc dot gnu.org
  2022-06-28 10:42 ` jakub at gcc dot gnu.org
  2023-07-07  9:21 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-04-08 12:02 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.3                        |10.4

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 10.3 is being released, retargeting bugs to GCC 10.4.

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

* [Bug tree-optimization/98444] [10 Regression] compile error with -ftracer and -Werror=format-overflow
  2020-12-25 15:29 [Bug tree-optimization/98444] New: [10 Regression] compile error with -ftracer and -Werror=format-overflow drfiemost at email dot it
                   ` (2 preceding siblings ...)
  2021-04-08 12:02 ` rguenth at gcc dot gnu.org
@ 2022-06-28 10:42 ` jakub at gcc dot gnu.org
  2023-07-07  9:21 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-28 10:42 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.4                        |10.5

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 10.4 is being released, retargeting bugs to GCC 10.5.

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

* [Bug tree-optimization/98444] [10 Regression] compile error with -ftracer and -Werror=format-overflow
  2020-12-25 15:29 [Bug tree-optimization/98444] New: [10 Regression] compile error with -ftracer and -Werror=format-overflow drfiemost at email dot it
                   ` (3 preceding siblings ...)
  2022-06-28 10:42 ` jakub at gcc dot gnu.org
@ 2023-07-07  9:21 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07  9:21 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |10.5.0
             Status|NEW                         |RESOLVED
   Target Milestone|10.5                        |11.0
         Resolution|---                         |FIXED

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed in GCC 11.

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

end of thread, other threads:[~2023-07-07  9:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-25 15:29 [Bug tree-optimization/98444] New: [10 Regression] compile error with -ftracer and -Werror=format-overflow drfiemost at email dot it
2020-12-27 20:05 ` [Bug tree-optimization/98444] " msebor at gcc dot gnu.org
2021-01-14  8:13 ` rguenth at gcc dot gnu.org
2021-04-08 12:02 ` rguenth at gcc dot gnu.org
2022-06-28 10:42 ` jakub at gcc dot gnu.org
2023-07-07  9:21 ` rguenth 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).