public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/103012] New: ICE with #pragma GCC optimize followed by long line
@ 2021-10-31  9:42 pinskia at gcc dot gnu.org
  2021-10-31  9:43 ` [Bug c++/103012] " pinskia at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-10-31  9:42 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103012
           Summary: ICE with #pragma GCC optimize followed by long line
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

t0.cc:1:26: internal compiler error: in linemap_add, at libcpp/line-map.c:502
    1 | #pragma GCC optimize("Og")
      |                          ^
0x2094272 linemap_add(line_maps*, lc_reason, unsigned int, char const*,
unsigned int)
        /home/apinski/src/upstream-gcc/gcc/libcpp/line-map.c:502
0x2094486 linemap_line_start(line_maps*, unsigned int, unsigned int)
        /home/apinski/src/upstream-gcc/gcc/libcpp/line-map.c:827
0x2094798 linemap_position_for_column(line_maps*, unsigned int)
        /home/apinski/src/upstream-gcc/gcc/libcpp/line-map.c:898
0x208fd00 _cpp_lex_direct
        /home/apinski/src/upstream-gcc/gcc/libcpp/lex.c:2994
0x2091670 _cpp_lex_token
        /home/apinski/src/upstream-gcc/gcc/libcpp/lex.c:2810
0x207fddf lex_macro_node
        /home/apinski/src/upstream-gcc/gcc/libcpp/directives.c:601
0x20805a2 do_define
        /home/apinski/src/upstream-gcc/gcc/libcpp/directives.c:639
0x20836ef run_directive
        /home/apinski/src/upstream-gcc/gcc/libcpp/directives.c:589
0x20837a7 cpp_define(cpp_reader*, char const*)
        /home/apinski/src/upstream-gcc/gcc/libcpp/directives.c:2511
0x20837fb cpp_define_unused(cpp_reader*, char const*)
        /home/apinski/src/upstream-gcc/gcc/libcpp/directives.c:2520
0xc7a234 c_cpp_builtins_optimize_pragma(cpp_reader*, tree_node*, tree_node*)
        /home/apinski/src/upstream-gcc/gcc/gcc/c-family/c-cppbuiltin.c:600
0xc9c8e3 handle_pragma_optimize
        /home/apinski/src/upstream-gcc/gcc/gcc/c-family/c-pragma.c:997
0xb35c40 cp_parser_pragma
        /home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.c:47773
0xb6cbfb cp_parser_toplevel_declaration
        /home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.c:14852
0xb6cbfb cp_parser_toplevel_declaration
        /home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.c:14843
0xb6cbfb cp_parser_translation_unit
        /home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.c:4987
0xb6cbfb c_parse_file()
        /home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.c:47832
0xc9a5ed c_common_parse_file()
        /home/apinski/src/upstream-gcc/gcc/gcc/c-family/c-opts.c:1237
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.

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

* [Bug c++/103012] ICE with #pragma GCC optimize followed by long line
  2021-10-31  9:42 [Bug c++/103012] New: ICE with #pragma GCC optimize followed by long line pinskia at gcc dot gnu.org
@ 2021-10-31  9:43 ` pinskia at gcc dot gnu.org
  2021-10-31  9:43 ` pinskia at gcc dot gnu.org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-10-31  9:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 51714
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51714&action=edit
testcase

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

* [Bug c++/103012] ICE with #pragma GCC optimize followed by long line
  2021-10-31  9:42 [Bug c++/103012] New: ICE with #pragma GCC optimize followed by long line pinskia at gcc dot gnu.org
  2021-10-31  9:43 ` [Bug c++/103012] " pinskia at gcc dot gnu.org
@ 2021-10-31  9:43 ` pinskia at gcc dot gnu.org
  2021-11-01  9:42 ` marxin at gcc dot gnu.org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-10-31  9:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Someone else has to reduce the testcase and such.
I found this while trying to reduce PR 102990.

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

* [Bug c++/103012] ICE with #pragma GCC optimize followed by long line
  2021-10-31  9:42 [Bug c++/103012] New: ICE with #pragma GCC optimize followed by long line pinskia at gcc dot gnu.org
  2021-10-31  9:43 ` [Bug c++/103012] " pinskia at gcc dot gnu.org
  2021-10-31  9:43 ` pinskia at gcc dot gnu.org
@ 2021-11-01  9:42 ` marxin at gcc dot gnu.org
  2021-11-01  9:52 ` marxin at gcc dot gnu.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-11-01  9:42 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-11-01
     Ever confirmed|0                           |1
                 CC|                            |marxin at gcc dot gnu.org

--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
I'm reducing that right now.

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

* [Bug c++/103012] ICE with #pragma GCC optimize followed by long line
  2021-10-31  9:42 [Bug c++/103012] New: ICE with #pragma GCC optimize followed by long line pinskia at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-11-01  9:42 ` marxin at gcc dot gnu.org
@ 2021-11-01  9:52 ` marxin at gcc dot gnu.org
  2021-11-07  3:11 ` [Bug c++/103012] [11/12 Regression] ICE with #pragma GCC optimize followed by long line (4047 long) pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-11-01  9:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
I've reduced that to:

#pragma GCC optimize"Og"
      template     inline void     template     void    
__valarray_copy_construct0         template     inline void     __valarray_fill
0         template<typename _Tp>     inline void     __valarray_fill0        
template<typename _Tp>     inline void     templatetypename _Tp>     inline
__valarray_copy0          typename >     inline void     __valarray_copy0      
   templatetypename _Tp>     inline void     templatetypename _Tp>     inline
__valarray_copy0          typename >     inline void     __valarray_copy0      
   templatetypename _Tp>     inline void     templatetypename _Tp>     inline
__valarray_copy0         template     inline     _Tp>::_Array0     : _M_data 0 
   template<typename _Tp>     inline     _Array<_Tp>::_Array0     : _M_data 0  
  template<typename _Tp>     inline     _Array<_Tp>::_Array0     : _M_data0    
    template<typename _Tp>     inline _Tp*     _Array<_Tp>::begin 0 const      
  template<typename _Tp> inline void template inline void
_Array_augmented___plus0  template void _Array_augmented___plus0  template
inline void _Array_augmented___plus0  template inline void
_Array_augmented___plus0  template void _Array_augmented___plus0  template
inline void _Array_augmented___plus0  _Tp void template void
_Array_augmented___plus0  templatetypename _Tpvoid _Array_augmented___plus0 
typename _Tp> _Array_augmented___plus0  templatetypename _Tp, _Dom> void
typename inline void template<_Tpinline template<_Tpclass > void
templatetypename _Tpinline void _Array_augmented___minus0  typename inline void
template<typename _Tp, class _Dom> _Array_augmented___minus  typename _Tp>
_Array_augmented___minus  template<typename _Tp> inline void
_Array_augmented___minus  template<typename _Tp, class _Dom> void
_Array_augmented___minus  template<typename _Tp> void _Array_augmented___minus 
template<typename _Tp> void _Array_augmented___minus  template<typename _Tp,
class _Dom> void _Array_augmented___minus     template<typename _Tp> inline
void template<_Tpinline _Array_augmented___multiplies  templatetypename _Tp,
_Dom> void template<_Tpinline template<_Tpinline _Array_augmented___multiplies 
templatetypename _Tp, _Dom> void template<_Tpinline
_Array_augmented___multiplies  templatetypename _Tp> inline templatetypename
_Tpclass _Dom> void _Array_augmented___multiplies0  typename void
_Array_augmented___multiplies0  template<typename _Tp> void
_Array_augmented___multiplies0  template<typename _Tp, class _Dom> void
_Array_augmented___multiplies0     template<typename _Tp> inline void
_Array_augmented___divides0  template<typename _Tp> inline void
_Array_augmented___divides0  template<typename _Tp, class _Dom> void
_Array_augmented___divides0  template<typename _Tp> inline void
_Array_augmented___divides0  template<typename _Tp> inline void
_Array_augmented___divides0  template<typename _Tp, class _Dom> void
_Array_augmented___divides0  template<typename _Tp> inline void
_Array_augmented___divides0  template<typename _Tp> inline void
_Array_augmented___divides0  template<typename _Tp, class _Dom> void
_Array_augmented___divides()  template<typename _Tp> void
_Array_augmented___divides()  template<typename _Tp> void
_Array_augmented___divides0  template void _Array_augmented___divides0    
template inline void _Array_augmented___modulus0  template inline void
_Array_augmented___modulus0  template void _Array_augmented___modulus0 
template inline void _Array_augmented___modulus0  template inline void
_Array_augmented___modulus0  template void _Array_augmented___modulus0 
template inline void _Array_augmented___modulus0  template inline void
_Array_augmented___modulus0  template void _Array_augmented___modulus0 
template void _Array_augmented___modulus0  template void
_Array_augmented___modulus0  template void _Array_augmented___modulus0    
template inline void _Array_augmented___bitwise_xor0  template void inline
inline inline _Array_augmented___bitwise_xor0  template void
_Array_augmented___bitwise_xor0  template void _Array_augmented___bitwise_xor0 
template void _Array_augmented___bitwise_xor0  template void

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

* [Bug c++/103012] [11/12 Regression] ICE with #pragma GCC optimize followed by long line (4047 long)
  2021-10-31  9:42 [Bug c++/103012] New: ICE with #pragma GCC optimize followed by long line pinskia at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-11-01  9:52 ` marxin at gcc dot gnu.org
@ 2021-11-07  3:11 ` pinskia at gcc dot gnu.org
  2021-11-08  8:16 ` marxin at gcc dot gnu.org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-07  3:11 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.3
      Known to fail|                            |11.1.0
           Keywords|                            |needs-bisection
            Summary|ICE with #pragma GCC        |[11/12 Regression] ICE with
                   |optimize followed by long   |#pragma GCC optimize
                   |line                        |followed by long line (4047
                   |                            |long)
      Known to work|                            |10.1.0, 7.5.0

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So decent testcase with macros, though you need -save-temps or preprocess it
beforehand if you are invoking cc1plus directly.
#pragma GCC optimize "Og"
#define a1(a) a
#define a2(a) a1(a)a1(a)
#define a4(a) a2(a)a2(a)
#define a8(a) a4(a)a4(a)
#define a16(a) a8(a)a8(a)
#define a32(a) a16(a)a16(a)
#define a64(a) a32(a)a32(a)
#define a128(a) a64(a)a64(a)
#define a256(a) a128(a)a128(a)
#define a512(a) a256(a)a256(a)
#define a1024(a) a512(a)a512(a)
#define a2048(a) a1024(a)a1024(a)
a2048(a)
---------- CUT ------
What I found also is the line needs to be 4047 characters long. The above line
will a little longer around 4096ish.

Also this worked at r10-6101 but failed at r11-6338.

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

* [Bug c++/103012] [11/12 Regression] ICE with #pragma GCC optimize followed by long line (4047 long)
  2021-10-31  9:42 [Bug c++/103012] New: ICE with #pragma GCC optimize followed by long line pinskia at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-11-07  3:11 ` [Bug c++/103012] [11/12 Regression] ICE with #pragma GCC optimize followed by long line (4047 long) pinskia at gcc dot gnu.org
@ 2021-11-08  8:16 ` marxin at gcc dot gnu.org
  2021-12-28 11:49 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-11-08  8:16 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nathan at gcc dot gnu.org
           Keywords|needs-bisection             |

--- Comment #6 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r11-338-g2a0225e47868fbfc.

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

* [Bug c++/103012] [11/12 Regression] ICE with #pragma GCC optimize followed by long line (4047 long)
  2021-10-31  9:42 [Bug c++/103012] New: ICE with #pragma GCC optimize followed by long line pinskia at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2021-11-08  8:16 ` marxin at gcc dot gnu.org
@ 2021-12-28 11:49 ` jakub at gcc dot gnu.org
  2021-12-30 13:26 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-12-28 11:49 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

Untested fix.

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

* [Bug c++/103012] [11/12 Regression] ICE with #pragma GCC optimize followed by long line (4047 long)
  2021-10-31  9:42 [Bug c++/103012] New: ICE with #pragma GCC optimize followed by long line pinskia at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2021-12-28 11:49 ` jakub at gcc dot gnu.org
@ 2021-12-30 13:26 ` cvs-commit at gcc dot gnu.org
  2021-12-30 13:39 ` [Bug c++/103012] [11 " jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-12-30 13:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 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:1dbe26b949c6142b278ab7af2bac4545e8d524f2

commit r12-6151-g1dbe26b949c6142b278ab7af2bac4545e8d524f2
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Dec 30 14:25:19 2021 +0100

    c-family: Use BULTINS_LOCATION for predefined macros changed upon optimize
or target pragmas [PR103012]

    The following testcases ICE when an optimize or target pragma
    is followed by a long line (4096+ chars).
    This is because on such long lines we can't use columns anymore,
    but the cpp_define calls performed by c_cpp_builtins_optimize_pragma
    or from the backend hooks for target pragma are done on temporary
    buffers and expect to get columns from whatever line they appear on
    (which happens to be the long line after optimize/target pragma),
    and we run into:
     #0  fancy_abort (file=0x3abec67 "../../libcpp/line-map.c", line=502,
function=0x3abecfc "linemap_add") at ../../gcc/diagnostic.c:1986
     #1  0x0000000002e7c335 in linemap_add (set=0x7ffff7fca000,
reason=LC_RENAME, sysp=0, to_file=0x41287a0 "pr103012.i", to_line=3) at
../../libcpp/line-map.c:502
     #2  0x0000000002e7cc24 in linemap_line_start (set=0x7ffff7fca000,
to_line=3, max_column_hint=128) at ../../libcpp/line-map.c:827
     #3  0x0000000002e7ce2b in linemap_position_for_column (set=0x7ffff7fca000,
to_column=1) at ../../libcpp/line-map.c:898
     #4  0x0000000002e771f9 in _cpp_lex_direct (pfile=0x40c3b60) at
../../libcpp/lex.c:3592
     #5  0x0000000002e76c3e in _cpp_lex_token (pfile=0x40c3b60) at
../../libcpp/lex.c:3394
     #6  0x0000000002e610ef in lex_macro_node (pfile=0x40c3b60,
is_def_or_undef=true) at ../../libcpp/directives.c:601
     #7  0x0000000002e61226 in do_define (pfile=0x40c3b60) at
../../libcpp/directives.c:639
     #8  0x0000000002e610b2 in run_directive (pfile=0x40c3b60, dir_no=0,
buf=0x7fffffffd430 "__OPTIMIZE__ 1\n", count=14) at
../../libcpp/directives.c:589
     #9  0x0000000002e650c1 in cpp_define (pfile=0x40c3b60, str=0x2f784d1
"__OPTIMIZE__") at ../../libcpp/directives.c:2513
     #10 0x0000000002e65100 in cpp_define_unused (pfile=0x40c3b60,
str=0x2f784d1 "__OPTIMIZE__") at ../../libcpp/directives.c:2522
     #11 0x0000000000f50685 in c_cpp_builtins_optimize_pragma (pfile=0x40c3b60,
prev_tree=<optimization_node 0x7fffea042000>, cur_tree=<optimization_node
0x7fffea042020>)
         at ../../gcc/c-family/c-cppbuiltin.c:600
    assertion that LC_RENAME doesn't happen first.

    I think the right fix is emit those predefined macros upon
    optimize/target pragmas with BUILTINS_LOCATION, like we already do
    for those macros at the start of the TU, they don't appear in columns
    of the next line after it.  Another possibility would be to force them
    at the location of the pragma.

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

            PR c++/103012
    gcc/
            * config/i386/i386-c.c (ix86_pragma_target_parse): Perform
            cpp_define/cpp_undef calls with forced token locations
            BUILTINS_LOCATION.
            * config/arm/arm-c.c (arm_pragma_target_parse): Likewise.
            * config/aarch64/aarch64-c.c (aarch64_pragma_target_parse):
Likewise.
            * config/s390/s390-c.c (s390_pragma_target_parse): Likewise.
    gcc/c-family/
            * c-cppbuiltin.c (c_cpp_builtins_optimize_pragma): Perform
            cpp_define_unused/cpp_undef calls with forced token locations
            BUILTINS_LOCATION.
    gcc/testsuite/
            PR c++/103012
            * g++.dg/cpp/pr103012.C: New test.
            * g++.target/i386/pr103012.C: New test.

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

* [Bug c++/103012] [11 Regression] ICE with #pragma GCC optimize followed by long line (4047 long)
  2021-10-31  9:42 [Bug c++/103012] New: ICE with #pragma GCC optimize followed by long line pinskia at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2021-12-30 13:26 ` cvs-commit at gcc dot gnu.org
@ 2021-12-30 13:39 ` jakub at gcc dot gnu.org
  2022-01-24  9:20 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-12-30 13:39 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[11/12 Regression] ICE with |[11 Regression] ICE with
                   |#pragma GCC optimize        |#pragma GCC optimize
                   |followed by long line (4047 |followed by long line (4047
                   |long)                       |long)

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed on the trunk so far.

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

* [Bug c++/103012] [11 Regression] ICE with #pragma GCC optimize followed by long line (4047 long)
  2021-10-31  9:42 [Bug c++/103012] New: ICE with #pragma GCC optimize followed by long line pinskia at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2021-12-30 13:39 ` [Bug c++/103012] [11 " jakub at gcc dot gnu.org
@ 2022-01-24  9:20 ` cvs-commit at gcc dot gnu.org
  2022-01-24  9:29 ` jakub at gcc dot gnu.org
  2022-01-24  9:31 ` jakub at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-24  9:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 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:be66fad59a7f74f96f47c1ae7d9f0a8e2b9a5f9e

commit r11-9495-gbe66fad59a7f74f96f47c1ae7d9f0a8e2b9a5f9e
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Dec 30 14:25:19 2021 +0100

    c-family: Use BULTINS_LOCATION for predefined macros changed upon optimize
or target pragmas [PR103012]

    The following testcases ICE when an optimize or target pragma
    is followed by a long line (4096+ chars).
    This is because on such long lines we can't use columns anymore,
    but the cpp_define calls performed by c_cpp_builtins_optimize_pragma
    or from the backend hooks for target pragma are done on temporary
    buffers and expect to get columns from whatever line they appear on
    (which happens to be the long line after optimize/target pragma),
    and we run into:
     #0  fancy_abort (file=0x3abec67 "../../libcpp/line-map.c", line=502,
function=0x3abecfc "linemap_add") at ../../gcc/diagnostic.c:1986
     #1  0x0000000002e7c335 in linemap_add (set=0x7ffff7fca000,
reason=LC_RENAME, sysp=0, to_file=0x41287a0 "pr103012.i", to_line=3) at
../../libcpp/line-map.c:502
     #2  0x0000000002e7cc24 in linemap_line_start (set=0x7ffff7fca000,
to_line=3, max_column_hint=128) at ../../libcpp/line-map.c:827
     #3  0x0000000002e7ce2b in linemap_position_for_column (set=0x7ffff7fca000,
to_column=1) at ../../libcpp/line-map.c:898
     #4  0x0000000002e771f9 in _cpp_lex_direct (pfile=0x40c3b60) at
../../libcpp/lex.c:3592
     #5  0x0000000002e76c3e in _cpp_lex_token (pfile=0x40c3b60) at
../../libcpp/lex.c:3394
     #6  0x0000000002e610ef in lex_macro_node (pfile=0x40c3b60,
is_def_or_undef=true) at ../../libcpp/directives.c:601
     #7  0x0000000002e61226 in do_define (pfile=0x40c3b60) at
../../libcpp/directives.c:639
     #8  0x0000000002e610b2 in run_directive (pfile=0x40c3b60, dir_no=0,
buf=0x7fffffffd430 "__OPTIMIZE__ 1\n", count=14) at
../../libcpp/directives.c:589
     #9  0x0000000002e650c1 in cpp_define (pfile=0x40c3b60, str=0x2f784d1
"__OPTIMIZE__") at ../../libcpp/directives.c:2513
     #10 0x0000000002e65100 in cpp_define_unused (pfile=0x40c3b60,
str=0x2f784d1 "__OPTIMIZE__") at ../../libcpp/directives.c:2522
     #11 0x0000000000f50685 in c_cpp_builtins_optimize_pragma (pfile=0x40c3b60,
prev_tree=<optimization_node 0x7fffea042000>, cur_tree=<optimization_node
0x7fffea042020>)
         at ../../gcc/c-family/c-cppbuiltin.c:600
    assertion that LC_RENAME doesn't happen first.

    I think the right fix is emit those predefined macros upon
    optimize/target pragmas with BUILTINS_LOCATION, like we already do
    for those macros at the start of the TU, they don't appear in columns
    of the next line after it.  Another possibility would be to force them
    at the location of the pragma.

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

            PR c++/103012
    gcc/
            * config/i386/i386-c.c (ix86_pragma_target_parse): Perform
            cpp_define/cpp_undef calls with forced token locations
            BUILTINS_LOCATION.
            * config/arm/arm-c.c (arm_pragma_target_parse): Likewise.
            * config/aarch64/aarch64-c.c (aarch64_pragma_target_parse):
Likewise.
            * config/s390/s390-c.c (s390_pragma_target_parse): Likewise.
    gcc/c-family/
            * c-cppbuiltin.c (c_cpp_builtins_optimize_pragma): Perform
            cpp_define_unused/cpp_undef calls with forced token locations
            BUILTINS_LOCATION.
    gcc/testsuite/
            PR c++/103012
            * g++.dg/cpp/pr103012.C: New test.
            * g++.target/i386/pr103012.C: New test.

    (cherry picked from commit 1dbe26b949c6142b278ab7af2bac4545e8d524f2)

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

* [Bug c++/103012] [11 Regression] ICE with #pragma GCC optimize followed by long line (4047 long)
  2021-10-31  9:42 [Bug c++/103012] New: ICE with #pragma GCC optimize followed by long line pinskia at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2022-01-24  9:20 ` cvs-commit at gcc dot gnu.org
@ 2022-01-24  9:29 ` jakub at gcc dot gnu.org
  2022-01-24  9:31 ` jakub at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-01-24  9:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 11.3 too.

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

* [Bug c++/103012] [11 Regression] ICE with #pragma GCC optimize followed by long line (4047 long)
  2021-10-31  9:42 [Bug c++/103012] New: ICE with #pragma GCC optimize followed by long line pinskia at gcc dot gnu.org
                   ` (10 preceding siblings ...)
  2022-01-24  9:29 ` jakub at gcc dot gnu.org
@ 2022-01-24  9:31 ` jakub at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-01-24  9:31 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

end of thread, other threads:[~2022-01-24  9:31 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-31  9:42 [Bug c++/103012] New: ICE with #pragma GCC optimize followed by long line pinskia at gcc dot gnu.org
2021-10-31  9:43 ` [Bug c++/103012] " pinskia at gcc dot gnu.org
2021-10-31  9:43 ` pinskia at gcc dot gnu.org
2021-11-01  9:42 ` marxin at gcc dot gnu.org
2021-11-01  9:52 ` marxin at gcc dot gnu.org
2021-11-07  3:11 ` [Bug c++/103012] [11/12 Regression] ICE with #pragma GCC optimize followed by long line (4047 long) pinskia at gcc dot gnu.org
2021-11-08  8:16 ` marxin at gcc dot gnu.org
2021-12-28 11:49 ` jakub at gcc dot gnu.org
2021-12-30 13:26 ` cvs-commit at gcc dot gnu.org
2021-12-30 13:39 ` [Bug c++/103012] [11 " jakub at gcc dot gnu.org
2022-01-24  9:20 ` cvs-commit at gcc dot gnu.org
2022-01-24  9:29 ` jakub at gcc dot gnu.org
2022-01-24  9:31 ` 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).