public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/104472] New: ICE: SIGSEGV in cxx_eval_internal_function with __builtin_convertvector()
@ 2022-02-09 18:34 zsojka at seznam dot cz
  2022-02-10 11:51 ` [Bug c++/104472] ICE: SIGSEGV in cxx_eval_internal_function with __builtin_convertvector and -frounding-math jakub at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: zsojka at seznam dot cz @ 2022-02-09 18:34 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104472
           Summary: ICE: SIGSEGV in cxx_eval_internal_function with
                    __builtin_convertvector()
           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: zsojka at seznam dot cz
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu
            Target: x86_64-pc-linux-gnu

Created attachment 52397
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52397&action=edit
reduced testcase

Compiler output:
$ x86_64-pc-linux-gnu-g++ -frounding-math testcase.C -wrapper valgrind,-q
==29185== Invalid read of size 2
==29185==    at 0xE39E1F: cxx_eval_internal_function(constexpr_ctx const*,
tree_node*, bool, bool*, bool*) (constexpr.cc:1842)
==29185==    by 0xE2D5D6: cxx_eval_call_expression(constexpr_ctx const*,
tree_node*, bool, bool*, bool*) (constexpr.cc:2395)
==29185==    by 0xE3090C: cxx_eval_constant_expression(constexpr_ctx const*,
tree_node*, bool, bool*, bool*, tree_node**) (constexpr.cc:6637)
==29185==    by 0xE3D247: cxx_eval_binary_expression(constexpr_ctx const*,
tree_node*, bool, bool*, bool*) (constexpr.cc:3337)
==29185==    by 0xE302FB: cxx_eval_constant_expression(constexpr_ctx const*,
tree_node*, bool, bool*, bool*, tree_node**) (constexpr.cc:7014)
==29185==    by 0xE34956: cxx_eval_outermost_constant_expr(tree_node*, bool,
bool, bool, bool, tree_node*) (constexpr.cc:7709)
==29185==    by 0xE3739D: potential_constant_expression_1(tree_node*, bool,
bool, bool, int, tree_node**) (constexpr.cc:9285)
==29185==    by 0xE38148: potential_constant_expression_1 (constexpr.cc:9438)
==29185==    by 0xE38148: is_rvalue_constant_expression(tree_node*)
(constexpr.cc:9503)
==29185==    by 0xF635FC: cp_parser_constant_expression(cp_parser*, int, bool*,
bool) (parser.cc:10663)
==29185==    by 0xF636D1: cp_parser_initializer_clause(cp_parser*, bool*)
(parser.cc:25216)
==29185==    by 0xF66E5C: cp_parser_initializer(cp_parser*, bool*, bool*, bool)
(parser.cc:25156)
==29185==    by 0xF967B3: cp_parser_init_declarator(cp_parser*, int,
cp_decl_specifier_seq*, vec<deferred_access_check, va_gc, vl_embed>*, bool,
bool, int, bool*, tree_node**, unsigned int*, tree_node**) (parser.cc:22766)
==29185==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==29185== 
testcase.C:4:77: internal compiler error: Segmentation fault
    4 | V v = __builtin_convertvector (__builtin_convertvector ((V){5534}, F),
V) < 8;
      |                                                                        
    ^
0x167637f crash_signal
        /repo/gcc-trunk/gcc/toplev.cc:322
0xe39e1f cxx_eval_internal_function
        /repo/gcc-trunk/gcc/cp/constexpr.cc:1842
0xe2d5d6 cxx_eval_call_expression
        /repo/gcc-trunk/gcc/cp/constexpr.cc:2395
0xe3090c cxx_eval_constant_expression
        /repo/gcc-trunk/gcc/cp/constexpr.cc:6637
0xe3d247 cxx_eval_binary_expression
        /repo/gcc-trunk/gcc/cp/constexpr.cc:3337
0xe302fb cxx_eval_constant_expression
        /repo/gcc-trunk/gcc/cp/constexpr.cc:7014
0xe34956 cxx_eval_outermost_constant_expr
        /repo/gcc-trunk/gcc/cp/constexpr.cc:7709
0xe3739d potential_constant_expression_1
        /repo/gcc-trunk/gcc/cp/constexpr.cc:9285
0xe38148 potential_constant_expression_1(tree_node*, bool, bool, bool, int)
        /repo/gcc-trunk/gcc/cp/constexpr.cc:9438
0xe38148 is_rvalue_constant_expression(tree_node*)
        /repo/gcc-trunk/gcc/cp/constexpr.cc:9503
0xf635fc cp_parser_constant_expression
        /repo/gcc-trunk/gcc/cp/parser.cc:10663
0xf636d1 cp_parser_initializer_clause
        /repo/gcc-trunk/gcc/cp/parser.cc:25216
0xf66e5c cp_parser_initializer
        /repo/gcc-trunk/gcc/cp/parser.cc:25156
0xf967b3 cp_parser_init_declarator
        /repo/gcc-trunk/gcc/cp/parser.cc:22766
0xf710b3 cp_parser_simple_declaration
        /repo/gcc-trunk/gcc/cp/parser.cc:15286
0xfa16a5 cp_parser_declaration
        /repo/gcc-trunk/gcc/cp/parser.cc:14972
0xfa211a cp_parser_toplevel_declaration
        /repo/gcc-trunk/gcc/cp/parser.cc:14993
0xfa211a cp_parser_translation_unit
        /repo/gcc-trunk/gcc/cp/parser.cc:5012
0xfa211a c_parse_file()
        /repo/gcc-trunk/gcc/cp/parser.cc:48042
0x10d8b0d c_common_parse_file()
        /repo/gcc-trunk/gcc/c-family/c-opts.cc:1238
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

$ x86_64-pc-linux-gnu-g++ -v
Using built-in specs.
COLLECT_GCC=/repo/gcc-trunk/binary-latest-amd64/bin/x86_64-pc-linux-gnu-g++
COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-r12-7128-20220209090954-gc6bb1db76b3-checking-yes-rtl-df-extra-nobootstrap-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/12.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++
--enable-valgrind-annotations --disable-nls --enable-checking=yes,rtl,df,extra
--disable-bootstrap --with-cloog --with-ppl --with-isl
--build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu
--target=x86_64-pc-linux-gnu --with-ld=/usr/bin/x86_64-pc-linux-gnu-ld
--with-as=/usr/bin/x86_64-pc-linux-gnu-as --disable-libstdcxx-pch
--prefix=/repo/gcc-trunk//binary-trunk-r12-7128-20220209090954-gc6bb1db76b3-checking-yes-rtl-df-extra-nobootstrap-amd64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.0.1 20220209 (experimental) (GCC)

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

* [Bug c++/104472] ICE: SIGSEGV in cxx_eval_internal_function with __builtin_convertvector and -frounding-math
  2022-02-09 18:34 [Bug c++/104472] New: ICE: SIGSEGV in cxx_eval_internal_function with __builtin_convertvector() zsojka at seznam dot cz
@ 2022-02-10 11:51 ` jakub at gcc dot gnu.org
  2022-02-11 12:53 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-02-10 11:51 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-02-10
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org

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

Untested fix.

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

* [Bug c++/104472] ICE: SIGSEGV in cxx_eval_internal_function with __builtin_convertvector and -frounding-math
  2022-02-09 18:34 [Bug c++/104472] New: ICE: SIGSEGV in cxx_eval_internal_function with __builtin_convertvector() zsojka at seznam dot cz
  2022-02-10 11:51 ` [Bug c++/104472] ICE: SIGSEGV in cxx_eval_internal_function with __builtin_convertvector and -frounding-math jakub at gcc dot gnu.org
@ 2022-02-11 12:53 ` cvs-commit at gcc dot gnu.org
  2022-02-11 12:54 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-02-11 12:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 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:84993d94e13ad2ab3aee151bb5a5e767cf75d51e

commit r12-7197-g84993d94e13ad2ab3aee151bb5a5e767cf75d51e
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Feb 11 13:52:44 2022 +0100

    c++: Fix up constant expression __builtin_convertvector folding [PR104472]

    The following testcase ICEs, because due to the -frounding-math
    fold_const_call fails, which is it returns NULL, and returning NULL from
    cxx_eval* is wrong, all the callers rely on them to either return folded
    value or original with *non_constant_p = true.

    The following patch does that, and additionally falls through into the
    default case where there is diagnostics for the !ctx->quiet case too.

    2022-02-11  Jakub Jelinek  <jakub@redhat.com>

            PR c++/104472
            * constexpr.cc (cxx_eval_internal_function) <case IFN_VEC_CONVERT>:
            Only return fold_const_call result if it is non-NULL.  Otherwise
            fall through into the default: case to return t, set
*non_constant_p
            and emit diagnostics if needed.

            * g++.dg/cpp0x/constexpr-104472.C: New test.

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

* [Bug c++/104472] ICE: SIGSEGV in cxx_eval_internal_function with __builtin_convertvector and -frounding-math
  2022-02-09 18:34 [Bug c++/104472] New: ICE: SIGSEGV in cxx_eval_internal_function with __builtin_convertvector() zsojka at seznam dot cz
  2022-02-10 11:51 ` [Bug c++/104472] ICE: SIGSEGV in cxx_eval_internal_function with __builtin_convertvector and -frounding-math jakub at gcc dot gnu.org
  2022-02-11 12:53 ` cvs-commit at gcc dot gnu.org
@ 2022-02-11 12:54 ` jakub at gcc dot gnu.org
  2022-02-19  8:02 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-02-11 12:54 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

* [Bug c++/104472] ICE: SIGSEGV in cxx_eval_internal_function with __builtin_convertvector and -frounding-math
  2022-02-09 18:34 [Bug c++/104472] New: ICE: SIGSEGV in cxx_eval_internal_function with __builtin_convertvector() zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2022-02-11 12:54 ` jakub at gcc dot gnu.org
@ 2022-02-19  8:02 ` cvs-commit at gcc dot gnu.org
  2022-05-10  8:23 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-02-19  8:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 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:784deb1671629734322640520a7421106194f20a

commit r11-9602-g784deb1671629734322640520a7421106194f20a
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Feb 11 13:52:44 2022 +0100

    c++: Fix up constant expression __builtin_convertvector folding [PR104472]

    The following testcase ICEs, because due to the -frounding-math
    fold_const_call fails, which is it returns NULL, and returning NULL from
    cxx_eval* is wrong, all the callers rely on them to either return folded
    value or original with *non_constant_p = true.

    The following patch does that, and additionally falls through into the
    default case where there is diagnostics for the !ctx->quiet case too.

    2022-02-11  Jakub Jelinek  <jakub@redhat.com>

            PR c++/104472
            * constexpr.c (cxx_eval_internal_function) <case IFN_VEC_CONVERT>:
            Only return fold_const_call result if it is non-NULL.  Otherwise
            fall through into the default: case to return t, set
*non_constant_p
            and emit diagnostics if needed.

            * g++.dg/cpp0x/constexpr-104472.C: New test.

    (cherry picked from commit 84993d94e13ad2ab3aee151bb5a5e767cf75d51e)

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

* [Bug c++/104472] ICE: SIGSEGV in cxx_eval_internal_function with __builtin_convertvector and -frounding-math
  2022-02-09 18:34 [Bug c++/104472] New: ICE: SIGSEGV in cxx_eval_internal_function with __builtin_convertvector() zsojka at seznam dot cz
                   ` (3 preceding siblings ...)
  2022-02-19  8:02 ` cvs-commit at gcc dot gnu.org
@ 2022-05-10  8:23 ` cvs-commit at gcc dot gnu.org
  2022-05-11  6:24 ` cvs-commit at gcc dot gnu.org
  2022-05-11  6:36 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-10  8:23 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

commit r10-10677-gf755dd4bda6cb1ae5c6d8e9c3a285faea236d3c3
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Feb 11 13:52:44 2022 +0100

    c++: Fix up constant expression __builtin_convertvector folding [PR104472]

    The following testcase ICEs, because due to the -frounding-math
    fold_const_call fails, which is it returns NULL, and returning NULL from
    cxx_eval* is wrong, all the callers rely on them to either return folded
    value or original with *non_constant_p = true.

    The following patch does that, and additionally falls through into the
    default case where there is diagnostics for the !ctx->quiet case too.

    2022-02-11  Jakub Jelinek  <jakub@redhat.com>

            PR c++/104472
            * constexpr.c (cxx_eval_internal_function) <case IFN_VEC_CONVERT>:
            Only return fold_const_call result if it is non-NULL.  Otherwise
            fall through into the default: case to return t, set
*non_constant_p
            and emit diagnostics if needed.

            * g++.dg/cpp0x/constexpr-104472.C: New test.

    (cherry picked from commit 84993d94e13ad2ab3aee151bb5a5e767cf75d51e)

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

* [Bug c++/104472] ICE: SIGSEGV in cxx_eval_internal_function with __builtin_convertvector and -frounding-math
  2022-02-09 18:34 [Bug c++/104472] New: ICE: SIGSEGV in cxx_eval_internal_function with __builtin_convertvector() zsojka at seznam dot cz
                   ` (4 preceding siblings ...)
  2022-05-10  8:23 ` cvs-commit at gcc dot gnu.org
@ 2022-05-11  6:24 ` cvs-commit at gcc dot gnu.org
  2022-05-11  6:36 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-11  6:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

commit r9-10125-gc7e7ca915dc4c526b1f58a4808c7ec4ceaa30348
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Feb 11 13:52:44 2022 +0100

    c++: Fix up constant expression __builtin_convertvector folding [PR104472]

    The following testcase ICEs, because due to the -frounding-math
    fold_const_call fails, which is it returns NULL, and returning NULL from
    cxx_eval* is wrong, all the callers rely on them to either return folded
    value or original with *non_constant_p = true.

    The following patch does that, and additionally falls through into the
    default case where there is diagnostics for the !ctx->quiet case too.

    2022-02-11  Jakub Jelinek  <jakub@redhat.com>

            PR c++/104472
            * constexpr.c (cxx_eval_internal_function) <case IFN_VEC_CONVERT>:
            Only return fold_const_call result if it is non-NULL.  Otherwise
            fall through into the default: case to return t, set
*non_constant_p
            and emit diagnostics if needed.

            * g++.dg/cpp0x/constexpr-104472.C: New test.

    (cherry picked from commit 84993d94e13ad2ab3aee151bb5a5e767cf75d51e)

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

* [Bug c++/104472] ICE: SIGSEGV in cxx_eval_internal_function with __builtin_convertvector and -frounding-math
  2022-02-09 18:34 [Bug c++/104472] New: ICE: SIGSEGV in cxx_eval_internal_function with __builtin_convertvector() zsojka at seznam dot cz
                   ` (5 preceding siblings ...)
  2022-05-11  6:24 ` cvs-commit at gcc dot gnu.org
@ 2022-05-11  6:36 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-05-11  6:36 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

end of thread, other threads:[~2022-05-11  6:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-09 18:34 [Bug c++/104472] New: ICE: SIGSEGV in cxx_eval_internal_function with __builtin_convertvector() zsojka at seznam dot cz
2022-02-10 11:51 ` [Bug c++/104472] ICE: SIGSEGV in cxx_eval_internal_function with __builtin_convertvector and -frounding-math jakub at gcc dot gnu.org
2022-02-11 12:53 ` cvs-commit at gcc dot gnu.org
2022-02-11 12:54 ` jakub at gcc dot gnu.org
2022-02-19  8:02 ` cvs-commit at gcc dot gnu.org
2022-05-10  8:23 ` cvs-commit at gcc dot gnu.org
2022-05-11  6:24 ` cvs-commit at gcc dot gnu.org
2022-05-11  6:36 ` 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).