public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug preprocessor/101638] New: ICE with -Wtraditional
@ 2021-07-27 10:29 rguenth at gcc dot gnu.org
  2021-08-04 13:16 ` [Bug preprocessor/101638] " marxin at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-27 10:29 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101638
           Summary: ICE with -Wtraditional
           Product: gcc
           Version: 11.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: preprocessor
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

With recent glibc head includes

> cat t.c
#include <security/pam_modules.h>
#include <stdlib.h>

ICEs preprocessing the above with -Wtraditional

> gcc t.c -c -Wtraditional
In file included from /usr/include/features.h:488,
                 from /usr/include/bits/libc-header-start.h:33,
                 from /usr/include/stdlib.h:25,
                 from t.c:2:
/usr/include/sys/cdefs.h:1: internal compiler error: Segmentation fault
    1 | /* Copyright (C) 1992-2021 Free Software Foundation, Inc.
      | 
0xdef92b internal_error(char const*, ...)
        ???:0
0xddd540 cpp_sys_macro_p(cpp_reader*)
        ???:0
0xf0f026 _cpp_parse_expr
        ???:0
0xf0e452 _cpp_handle_directive
        ???:0
0xf09324 _cpp_lex_token
        ???:0
0xf21485 c_lex_with_flags(tree_node**, unsigned int*, unsigned char*, int)
        ???:0
0x1417068 c_parse_file()
        ???:0
0x1414d1b c_common_parse_file()
        ???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://bugs.opensuse.org/> for instructions.

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

* [Bug preprocessor/101638] ICE with -Wtraditional
  2021-07-27 10:29 [Bug preprocessor/101638] New: ICE with -Wtraditional rguenth at gcc dot gnu.org
@ 2021-08-04 13:16 ` marxin at gcc dot gnu.org
  2021-08-11 17:05 ` [Bug preprocessor/101638] [11/12 Regression] ICE with -Wtraditional since r11-4953-g1d00f8c86324c40a harald at gigawatt dot nl
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-08-04 13:16 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-08-04
             Status|UNCONFIRMED                 |NEW
                 CC|                            |jsm28 at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Reduced test-case:

$ cat y.c
# define __GNUC_PREREQ(maj, min) 0

# define __glibc_has_attribute(attr) __has_attribute (attr)
#if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__deprecated__)
#endif

$ gcc y.c -Wtraditional -c
y.c:1: internal compiler error: Segmentation fault
    1 | # define __GNUC_PREREQ(maj, min) 0
      | 
0xeb7f3a crash_signal
        /home/marxin/Programming/gcc/gcc/toplev.c:328
0x7ffff786239f ???
        ../sysdeps/unix/sysv/linux/sigaction.c:10
0x1b8a148 cpp_sys_macro_p(cpp_reader*)
        /home/marxin/Programming/gcc/libcpp/macro.c:3130
0x1b79158 cpp_classify_number(cpp_reader*, cpp_token const*, char const**,
unsigned int)
        /home/marxin/Programming/gcc/libcpp/expr.c:786
0x1b7ae12 eval_token
        /home/marxin/Programming/gcc/libcpp/expr.c:1136
0x1b7ae12 _cpp_parse_expr
        /home/marxin/Programming/gcc/libcpp/expr.c:1354
0x1b73459 do_if
        /home/marxin/Programming/gcc/libcpp/directives.c:2055
0x1b75469 _cpp_handle_directive
        /home/marxin/Programming/gcc/libcpp/directives.c:553
0x1b846f0 _cpp_lex_token
        /home/marxin/Programming/gcc/libcpp/lex.c:2819
0x1b8c597 cpp_get_token_1
        /home/marxin/Programming/gcc/libcpp/macro.c:2845
0x95627a c_lex_with_flags(tree_node**, unsigned int*, unsigned char*, int)
        /home/marxin/Programming/gcc/gcc/c-family/c-lex.c:483
0x8d2f8b c_lex_one_token
        /home/marxin/Programming/gcc/gcc/c/c-parser.c:279
0x8d3c91 c_parser_peek_token(c_parser*)
        /home/marxin/Programming/gcc/gcc/c/c-parser.c:483
0x9009cb c_parse_file()
        /home/marxin/Programming/gcc/gcc/c/c-parser.c:22115
0x964ce9 c_common_parse_file()
        /home/marxin/Programming/gcc/gcc/c-family/c-opts.c:1223
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Started with r11-4953-g1d00f8c86324c40a.

==421== Invalid read of size 1
==421==    at 0x1B8A148: cpp_sys_macro_p(cpp_reader*) (macro.c:3130)
==421==    by 0x1B79158: cpp_classify_number(cpp_reader*, cpp_token const*,
char const**, unsigned int) (expr.c:786)
==421==    by 0x1B7AE12: eval_token (expr.c:1136)
==421==    by 0x1B7AE12: _cpp_parse_expr (expr.c:1354)
==421==    by 0x1B73459: do_if(cpp_reader*) (directives.c:2055)
==421==    by 0x1B75469: _cpp_handle_directive (directives.c:553)
==421==    by 0x1B846F0: _cpp_lex_token (lex.c:2819)
==421==    by 0x1B8C597: cpp_get_token_1(cpp_reader*, unsigned int*)
(macro.c:2845)
==421==    by 0x95627A: c_lex_with_flags(tree_node**, unsigned int*, unsigned
char*, int) (c-lex.c:483)
==421==    by 0x8D2F8B: c_lex_one_token(c_parser*, c_token*, bool)
(c-parser.c:279)
==421==    by 0x8D3C91: c_parser_peek_token(c_parser*) (c-parser.c:483)
==421==    by 0x9009CB: c_parse_file() (c-parser.c:22115)
==421==    by 0x964CE9: c_common_parse_file() (c-opts.c:1223)
==421==  Address 0x1e is not stack'd, malloc'd or (recently) free'd

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

* [Bug preprocessor/101638] [11/12 Regression] ICE with -Wtraditional since r11-4953-g1d00f8c86324c40a
  2021-07-27 10:29 [Bug preprocessor/101638] New: ICE with -Wtraditional rguenth at gcc dot gnu.org
  2021-08-04 13:16 ` [Bug preprocessor/101638] " marxin at gcc dot gnu.org
@ 2021-08-11 17:05 ` harald at gigawatt dot nl
  2021-08-11 19:12 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: harald at gigawatt dot nl @ 2021-08-11 17:05 UTC (permalink / raw)
  To: gcc-bugs

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

Harald van Dijk <harald at gigawatt dot nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |harald at gigawatt dot nl

--- Comment #2 from Harald van Dijk <harald at gigawatt dot nl> ---
*** Bug 101864 has been marked as a duplicate of this bug. ***

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

* [Bug preprocessor/101638] [11/12 Regression] ICE with -Wtraditional since r11-4953-g1d00f8c86324c40a
  2021-07-27 10:29 [Bug preprocessor/101638] New: ICE with -Wtraditional rguenth at gcc dot gnu.org
  2021-08-04 13:16 ` [Bug preprocessor/101638] " marxin at gcc dot gnu.org
  2021-08-11 17:05 ` [Bug preprocessor/101638] [11/12 Regression] ICE with -Wtraditional since r11-4953-g1d00f8c86324c40a harald at gigawatt dot nl
@ 2021-08-11 19:12 ` jakub at gcc dot gnu.org
  2021-08-12 20:40 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-08-11 19:12 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 51291
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51291&action=edit
gcc12-pr101638.patch

Untested fix.

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

* [Bug preprocessor/101638] [11/12 Regression] ICE with -Wtraditional since r11-4953-g1d00f8c86324c40a
  2021-07-27 10:29 [Bug preprocessor/101638] New: ICE with -Wtraditional rguenth at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-08-11 19:12 ` jakub at gcc dot gnu.org
@ 2021-08-12 20:40 ` cvs-commit at gcc dot gnu.org
  2021-08-12 22:55 ` cvs-commit at gcc dot gnu.org
  2021-08-12 22:56 ` jakub at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-08-12 20:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:408d88af60e3268f7fad59fa393ec7e28922c435

commit r12-2890-g408d88af60e3268f7fad59fa393ec7e28922c435
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Aug 12 22:38:18 2021 +0200

    libcpp: Fix ICE with -Wtraditional preprocessing [PR101638]

    The following testcase ICEs in cpp_sys_macro_p, because cpp_sys_macro_p
    is called for a builtin macro which doesn't use node->value.macro union
    member but a different one and so dereferencing it ICEs.
    As the testcase is distilled from contemporary glibc headers, it means
    basically -Wtraditional now ICEs on almost everything.

    The fix can be either the patch below, return true for builtin macros,
    or we could instead return false for builtin macros, or the fix could
    be also (untested):
    --- libcpp/expr.c       2021-05-07 10:34:46.345122608 +0200
    +++ libcpp/expr.c       2021-08-12 09:54:01.837556365 +0200
    @@ -783,13 +783,13 @@ cpp_classify_number (cpp_reader *pfile,

           /* Traditional C only accepted the 'L' suffix.
              Suppress warning about 'LL' with -Wno-long-long.  */
    -      if (CPP_WTRADITIONAL (pfile) && ! cpp_sys_macro_p (pfile))
    +      if (CPP_WTRADITIONAL (pfile))
            {
              int u_or_i = (result & (CPP_N_UNSIGNED|CPP_N_IMAGINARY));
              int large = (result & CPP_N_WIDTH) == CPP_N_LARGE
                           && CPP_OPTION (pfile, cpp_warn_long_long);

    -         if (u_or_i || large)
    +         if ((u_or_i || large) && ! cpp_sys_macro_p (pfile))
                cpp_warning_with_line (pfile, large ? CPP_W_LONG_LONG :
CPP_W_TRADITIONAL,
                                       virtual_location, 0,
                                       "traditional C rejects the \"%.*s\"
suffix",
    The builtin macros at least currently don't add any suffixes
    or numbers -Wtraditional would like to warn about.  For floating
    point suffixes, -Wtraditional calls cpp_sys_macro_p only right
    away before emitting the warning, but in the above case the ICE
    is because cpp_sys_macro_p is called even if the number doesn't
    have any suffixes (that is I think always for builtin macros
    right now).

    2021-08-12  Jakub Jelinek  <jakub@redhat.com>

            PR preprocessor/101638
            * macro.c (cpp_sys_macro_p): Return true instead of
            crashing on builtin macros.

            * gcc.dg/cpp/pr101638.c: New test.

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

* [Bug preprocessor/101638] [11/12 Regression] ICE with -Wtraditional since r11-4953-g1d00f8c86324c40a
  2021-07-27 10:29 [Bug preprocessor/101638] New: ICE with -Wtraditional rguenth at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-08-12 20:40 ` cvs-commit at gcc dot gnu.org
@ 2021-08-12 22:55 ` cvs-commit at gcc dot gnu.org
  2021-08-12 22:56 ` jakub at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-08-12 22:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:b1c4b1c100889c0f0b11dd79ca083dfb3bc00f4a

commit r11-8861-gb1c4b1c100889c0f0b11dd79ca083dfb3bc00f4a
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Aug 12 22:38:18 2021 +0200

    libcpp: Fix ICE with -Wtraditional preprocessing [PR101638]

    The following testcase ICEs in cpp_sys_macro_p, because cpp_sys_macro_p
    is called for a builtin macro which doesn't use node->value.macro union
    member but a different one and so dereferencing it ICEs.
    As the testcase is distilled from contemporary glibc headers, it means
    basically -Wtraditional now ICEs on almost everything.

    The fix can be either the patch below, return true for builtin macros,
    or we could instead return false for builtin macros, or the fix could
    be also (untested):
    --- libcpp/expr.c       2021-05-07 10:34:46.345122608 +0200
    +++ libcpp/expr.c       2021-08-12 09:54:01.837556365 +0200
    @@ -783,13 +783,13 @@ cpp_classify_number (cpp_reader *pfile,

           /* Traditional C only accepted the 'L' suffix.
              Suppress warning about 'LL' with -Wno-long-long.  */
    -      if (CPP_WTRADITIONAL (pfile) && ! cpp_sys_macro_p (pfile))
    +      if (CPP_WTRADITIONAL (pfile))
            {
              int u_or_i = (result & (CPP_N_UNSIGNED|CPP_N_IMAGINARY));
              int large = (result & CPP_N_WIDTH) == CPP_N_LARGE
                           && CPP_OPTION (pfile, cpp_warn_long_long);

    -         if (u_or_i || large)
    +         if ((u_or_i || large) && ! cpp_sys_macro_p (pfile))
                cpp_warning_with_line (pfile, large ? CPP_W_LONG_LONG :
CPP_W_TRADITIONAL,
                                       virtual_location, 0,
                                       "traditional C rejects the \"%.*s\"
suffix",
    The builtin macros at least currently don't add any suffixes
    or numbers -Wtraditional would like to warn about.  For floating
    point suffixes, -Wtraditional calls cpp_sys_macro_p only right
    away before emitting the warning, but in the above case the ICE
    is because cpp_sys_macro_p is called even if the number doesn't
    have any suffixes (that is I think always for builtin macros
    right now).

    2021-08-12  Jakub Jelinek  <jakub@redhat.com>

            PR preprocessor/101638
            * macro.c (cpp_sys_macro_p): Return true instead of
            crashing on builtin macros.

            * gcc.dg/cpp/pr101638.c: New test.

    (cherry picked from commit 408d88af60e3268f7fad59fa393ec7e28922c435)

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

* [Bug preprocessor/101638] [11/12 Regression] ICE with -Wtraditional since r11-4953-g1d00f8c86324c40a
  2021-07-27 10:29 [Bug preprocessor/101638] New: ICE with -Wtraditional rguenth at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-08-12 22:55 ` cvs-commit at gcc dot gnu.org
@ 2021-08-12 22:56 ` jakub at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-08-12 22:56 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |11.3

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

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

end of thread, other threads:[~2021-08-12 22:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-27 10:29 [Bug preprocessor/101638] New: ICE with -Wtraditional rguenth at gcc dot gnu.org
2021-08-04 13:16 ` [Bug preprocessor/101638] " marxin at gcc dot gnu.org
2021-08-11 17:05 ` [Bug preprocessor/101638] [11/12 Regression] ICE with -Wtraditional since r11-4953-g1d00f8c86324c40a harald at gigawatt dot nl
2021-08-11 19:12 ` jakub at gcc dot gnu.org
2021-08-12 20:40 ` cvs-commit at gcc dot gnu.org
2021-08-12 22:55 ` cvs-commit at gcc dot gnu.org
2021-08-12 22:56 ` 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).