public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101030] New: gcc internal error with Wconversion
@ 2021-06-11 12:24 chrishair85 at gmail dot com
  2021-08-12 23:19 ` [Bug c++/101030] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: chrishair85 at gmail dot com @ 2021-06-11 12:24 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101030
           Summary: gcc internal error with Wconversion
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chrishair85 at gmail dot com
  Target Milestone: ---

template <int N>
struct jj {
    int ii[N ?: 1];
};

int main() {
    jj<2> kk;
}

g++ -Wconversion dies with
version 8 to 11

changing template<int N> to template<unsigned long N> makes it work

Regards

<source>:4:18: internal compiler error: Segmentation fault
    4 |     int ii[N ?: 1];
      |                  ^
0x1780bf9 internal_error(char const*, ...)
        ???:0
0x6d96a9 cp_convert_and_check(tree_node*, tree_node*, int)
        ???:0
0x6f2dc8 grokdeclarator(cp_declarator const*, cp_decl_specifier_seq*,
decl_context, int, tree_node**)
        ???:0
0x707dd4 grokfield(cp_declarator const*, cp_decl_specifier_seq*, tree_node*,
bool, tree_node*, tree_node*)
        ???:0
0x7c0cab c_parse_file()
        ???:0
0x892aa2 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://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1

Rgds

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

* [Bug c++/101030] [9/10/11/12 Regression] gcc internal error with Wconversion
  2021-06-11 12:24 [Bug c++/101030] New: gcc internal error with Wconversion chrishair85 at gmail dot com
@ 2021-08-12 23:19 ` pinskia at gcc dot gnu.org
  2021-08-12 23:33 ` [Bug c++/101030] [9/10/11/12 Regression] ICE with -Wconversion and a?:b extension in template argument pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-12 23:19 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |8.1.0
   Target Milestone|---                         |9.5
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
      Known to work|                            |7.5.0
   Last reconfirmed|                            |2021-08-12
            Summary|gcc internal error with     |[9/10/11/12 Regression] gcc
                   |Wconversion                 |internal error with
                   |                            |Wconversion

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

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

* [Bug c++/101030] [9/10/11/12 Regression] ICE with -Wconversion and a?:b extension in template argument
  2021-06-11 12:24 [Bug c++/101030] New: gcc internal error with Wconversion chrishair85 at gmail dot com
  2021-08-12 23:19 ` [Bug c++/101030] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
@ 2021-08-12 23:33 ` pinskia at gcc dot gnu.org
  2022-01-17 14:36 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-12 23:33 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[9/10/11/12 Regression] gcc |[9/10/11/12 Regression] ICE
                   |internal error with         |with -Wconversion and a?:b
                   |Wconversion                 |extension in template
                   |                            |argument

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Simple fix but I doubt it is the correct fix:
diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c
index 84ad6633c96..ddaf0036abc 100644
--- a/gcc/c-family/c-warn.c
+++ b/gcc/c-family/c-warn.c
@@ -1296,8 +1296,10 @@ conversion_warning (location_t loc, tree type, tree
expr, tree result)
     case COND_EXPR:
       {
        /* In case of COND_EXPR, we do not care about the type of
-          COND_EXPR, only about the conversion of each operand.  */
-       tree op1 = TREE_OPERAND (expr, 1);
+          COND_EXPR, only about the conversion of each operand
+          except if we had a?:b then we care about the original
+          expression.  */
+       tree op1 = TREE_OPERAND (expr, 1) ? TREE_OPERAND (expr, 1) :
TREE_OPERAND (expr, 0);
        tree op2 = TREE_OPERAND (expr, 2);

        return (conversion_warning (loc, type, op1, result)

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

* [Bug c++/101030] [9/10/11/12 Regression] ICE with -Wconversion and a?:b extension in template argument
  2021-06-11 12:24 [Bug c++/101030] New: gcc internal error with Wconversion chrishair85 at gmail dot com
  2021-08-12 23:19 ` [Bug c++/101030] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
  2021-08-12 23:33 ` [Bug c++/101030] [9/10/11/12 Regression] ICE with -Wconversion and a?:b extension in template argument pinskia at gcc dot gnu.org
@ 2022-01-17 14:36 ` rguenth at gcc dot gnu.org
  2022-03-29 14:51 ` mpolacek at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-17 14:36 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
I suspect that

        return ((op1 && conversion_warning (loc, type, op1, result))
                || (op2 && conversion_warning (loc, type, op2, result)));

is more to-the-point.  For the special case of the extension -Wconversion isn't
a good match.

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

* [Bug c++/101030] [9/10/11/12 Regression] ICE with -Wconversion and a?:b extension in template argument
  2021-06-11 12:24 [Bug c++/101030] New: gcc internal error with Wconversion chrishair85 at gmail dot com
                   ` (2 preceding siblings ...)
  2022-01-17 14:36 ` rguenth at gcc dot gnu.org
@ 2022-03-29 14:51 ` mpolacek at gcc dot gnu.org
  2022-03-30 14:23 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-03-29 14:51 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

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

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

* [Bug c++/101030] [9/10/11/12 Regression] ICE with -Wconversion and a?:b extension in template argument
  2021-06-11 12:24 [Bug c++/101030] New: gcc internal error with Wconversion chrishair85 at gmail dot com
                   ` (3 preceding siblings ...)
  2022-03-29 14:51 ` mpolacek at gcc dot gnu.org
@ 2022-03-30 14:23 ` cvs-commit at gcc dot gnu.org
  2022-03-30 14:24 ` [Bug c++/101030] [9/10/11 " mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-30 14:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:5db9ce171019f8915885cebd5cc5f4101bb926e6

commit r12-7922-g5db9ce171019f8915885cebd5cc5f4101bb926e6
Author: Marek Polacek <polacek@redhat.com>
Date:   Tue Mar 29 14:36:55 2022 -0400

    c-family: ICE with -Wconversion and A ?: B [PR101030]

    This patch fixes a crash in conversion_warning on a null expression.
    It is null because the testcase uses the GNU A ?: B extension.  We
    could also use op0 instead of op1 in this case, but it doesn't seem
    to be necessary.

            PR c++/101030

    gcc/c-family/ChangeLog:

            * c-warn.cc (conversion_warning) <case COND_EXPR>: Don't call
            conversion_warning when OP1 is null.

    gcc/testsuite/ChangeLog:

            * g++.dg/ext/cond5.C: New test.

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

* [Bug c++/101030] [9/10/11 Regression] ICE with -Wconversion and a?:b extension in template argument
  2021-06-11 12:24 [Bug c++/101030] New: gcc internal error with Wconversion chrishair85 at gmail dot com
                   ` (4 preceding siblings ...)
  2022-03-30 14:23 ` cvs-commit at gcc dot gnu.org
@ 2022-03-30 14:24 ` mpolacek at gcc dot gnu.org
  2022-03-30 14:27 ` cvs-commit at gcc dot gnu.org
  2022-03-30 14:28 ` [Bug c++/101030] [9/10 " mpolacek at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-03-30 14:24 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[9/10/11/12 Regression] ICE |[9/10/11 Regression] ICE
                   |with -Wconversion and a?:b  |with -Wconversion and a?:b
                   |extension in template       |extension in template
                   |argument                    |argument

--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed on trunk so far, will backport to 11 too.

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

* [Bug c++/101030] [9/10/11 Regression] ICE with -Wconversion and a?:b extension in template argument
  2021-06-11 12:24 [Bug c++/101030] New: gcc internal error with Wconversion chrishair85 at gmail dot com
                   ` (5 preceding siblings ...)
  2022-03-30 14:24 ` [Bug c++/101030] [9/10/11 " mpolacek at gcc dot gnu.org
@ 2022-03-30 14:27 ` cvs-commit at gcc dot gnu.org
  2022-03-30 14:28 ` [Bug c++/101030] [9/10 " mpolacek at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-30 14:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Marek Polacek
<mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:511e8b612287ad828c60f2f12c500ccfa26c275c

commit r11-9751-g511e8b612287ad828c60f2f12c500ccfa26c275c
Author: Marek Polacek <polacek@redhat.com>
Date:   Tue Mar 29 14:36:55 2022 -0400

    c-family: ICE with -Wconversion and A ?: B [PR101030]

    This patch fixes a crash in conversion_warning on a null expression.
    It is null because the testcase uses the GNU A ?: B extension.  We
    could also use op0 instead of op1 in this case, but it doesn't seem
    to be necessary.

            PR c++/101030

    gcc/c-family/ChangeLog:

            * c-warn.c (conversion_warning) <case COND_EXPR>: Don't call
            conversion_warning when OP1 is null.

    gcc/testsuite/ChangeLog:

            * g++.dg/ext/cond5.C: New test.

    (cherry picked from commit 5db9ce171019f8915885cebd5cc5f4101bb926e6)

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

* [Bug c++/101030] [9/10 Regression] ICE with -Wconversion and a?:b extension in template argument
  2021-06-11 12:24 [Bug c++/101030] New: gcc internal error with Wconversion chrishair85 at gmail dot com
                   ` (6 preceding siblings ...)
  2022-03-30 14:27 ` cvs-commit at gcc dot gnu.org
@ 2022-03-30 14:28 ` mpolacek at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-03-30 14:28 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[9/10/11 Regression] ICE    |[9/10 Regression] ICE with
                   |with -Wconversion and a?:b  |-Wconversion and a?:b
                   |extension in template       |extension in template
                   |argument                    |argument
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2022-03-30 14:28 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-11 12:24 [Bug c++/101030] New: gcc internal error with Wconversion chrishair85 at gmail dot com
2021-08-12 23:19 ` [Bug c++/101030] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
2021-08-12 23:33 ` [Bug c++/101030] [9/10/11/12 Regression] ICE with -Wconversion and a?:b extension in template argument pinskia at gcc dot gnu.org
2022-01-17 14:36 ` rguenth at gcc dot gnu.org
2022-03-29 14:51 ` mpolacek at gcc dot gnu.org
2022-03-30 14:23 ` cvs-commit at gcc dot gnu.org
2022-03-30 14:24 ` [Bug c++/101030] [9/10/11 " mpolacek at gcc dot gnu.org
2022-03-30 14:27 ` cvs-commit at gcc dot gnu.org
2022-03-30 14:28 ` [Bug c++/101030] [9/10 " mpolacek 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).