public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug modula2/109810] New: String literal exceeding array causes ICE
@ 2023-05-11 11:48 gaius at gcc dot gnu.org
  2023-05-11 11:49 ` [Bug modula2/109810] " gaius at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-05-11 11:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109810
           Summary: String literal exceeding array causes ICE
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: modula2
          Assignee: gaius at gcc dot gnu.org
          Reporter: gaius at gcc dot gnu.org
  Target Milestone: ---

As reported on the gm2 mailing list.  If a string literal exceeding the array
size is assigned then an ICE occurs.  For example:

MODULE highice ;

VAR
   a: ARRAY [0..0] OF CHAR ;
BEGIN
   a := '12'
END highice.

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

* [Bug modula2/109810] String literal exceeding array causes ICE
  2023-05-11 11:48 [Bug modula2/109810] New: String literal exceeding array causes ICE gaius at gcc dot gnu.org
@ 2023-05-11 11:49 ` gaius at gcc dot gnu.org
  2023-05-11 11:52 ` gaius at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-05-11 11:49 UTC (permalink / raw)
  To: gcc-bugs

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

Gaius Mulley <gaius at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2023-05-11

--- Comment #1 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Confirmed with the test code on gcc-14.

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

* [Bug modula2/109810] String literal exceeding array causes ICE
  2023-05-11 11:48 [Bug modula2/109810] New: String literal exceeding array causes ICE gaius at gcc dot gnu.org
  2023-05-11 11:49 ` [Bug modula2/109810] " gaius at gcc dot gnu.org
@ 2023-05-11 11:52 ` gaius at gcc dot gnu.org
  2023-05-11 22:06 ` gaius at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-05-11 11:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Gaius Mulley <gaius at gcc dot gnu.org> ---
gm2 -g highice.mod 
highice.mod:6:6: warning: string constant is too large to be assigned to the
array
    6 |    a := '12'
      |      ^~
*** WARNING *** there are active plugins, do not report this as a bug unless
you can reproduce it without enabling any plugins.
Event                            | Plugins
PLUGIN_FINISH                    | m2rte
during GIMPLE pass: lower
In function ‘_M2_highice_init’:
cc1gm2: internal compiler error: in constant_byte_string, at expr.cc:12378
0x725205 constant_byte_string
        ../../gcc-13.1.0-RC-20230419/gcc/expr.cc:12378
0x9dde49 c_strlen(tree_node*, int, c_strlen_data*, unsigned int)
        ../../gcc-13.1.0-RC-20230419/gcc/builtins.cc:609
0xbc4f43 gimple_fold_builtin_memory_op
        ../../gcc-13.1.0-RC-20230419/gcc/gimple-fold.cc:976
0xbc6b8c gimple_fold_builtin
        ../../gcc-13.1.0-RC-20230419/gcc/gimple-fold.cc:5018
0xbc6b8c gimple_fold_call
        ../../gcc-13.1.0-RC-20230419/gcc/gimple-fold.cc:5576
0xbc8a3b fold_stmt_1
        ../../gcc-13.1.0-RC-20230419/gcc/gimple-fold.cc:6328
0x1c11ae7 lower_stmt
        ../../gcc-13.1.0-RC-20230419/gcc/gimple-low.cc:793
0x1c12752 lower_sequence
        ../../gcc-13.1.0-RC-20230419/gcc/gimple-low.cc:229
0x1c12752 lower_gimple_bind
        ../../gcc-13.1.0-RC-20230419/gcc/gimple-low.cc:882
0x1c128fb lower_function_body
        ../../gcc-13.1.0-RC-20230419/gcc/gimple-low.cc:119
0x1c128fb execute
        ../../gcc-13.1.0-RC-20230419/gcc/gimple-low.cc:206
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

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

* [Bug modula2/109810] String literal exceeding array causes ICE
  2023-05-11 11:48 [Bug modula2/109810] New: String literal exceeding array causes ICE gaius at gcc dot gnu.org
  2023-05-11 11:49 ` [Bug modula2/109810] " gaius at gcc dot gnu.org
  2023-05-11 11:52 ` gaius at gcc dot gnu.org
@ 2023-05-11 22:06 ` gaius at gcc dot gnu.org
  2023-05-11 22:08 ` gaius at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-05-11 22:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Created attachment 55059
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55059&action=edit
Proposed fix

Here is a proposed patch with test code which has successfully bootstrapped on
x86_64 linux.

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

* [Bug modula2/109810] String literal exceeding array causes ICE
  2023-05-11 11:48 [Bug modula2/109810] New: String literal exceeding array causes ICE gaius at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-05-11 22:06 ` gaius at gcc dot gnu.org
@ 2023-05-11 22:08 ` gaius at gcc dot gnu.org
  2023-05-11 23:19 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-05-11 22:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Gaius Mulley <gaius at gcc dot gnu.org> ---
The patch improves the error virtual token accuracy, for example:

$ gm2 -g highice.mod 
highice.mod:6:6: error: string constant ‘12’ is too large to be assigned to the
array ‘a’
    6 |    a := '12'
      |    ~~^~~~~~~
$

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

* [Bug modula2/109810] String literal exceeding array causes ICE
  2023-05-11 11:48 [Bug modula2/109810] New: String literal exceeding array causes ICE gaius at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2023-05-11 22:08 ` gaius at gcc dot gnu.org
@ 2023-05-11 23:19 ` cvs-commit at gcc dot gnu.org
  2023-05-11 23:21 ` gaius at gcc dot gnu.org
  2023-07-28 18:28 ` cvs-commit at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-11 23:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Gaius Mulley <gaius@gcc.gnu.org>:

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

commit r14-743-gc787f593e62869ae0b230949b4791f4f3a26e50e
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date:   Fri May 12 00:15:28 2023 +0100

    PR modula2/109810 ICE fix when an array is assigned by a larger string

    This patch fixes an ICE when an array variable is assigned with
    a string which exceeds the array size.  It improves the accuracy
    of the virtual token used to indicate the error message.

    gcc/m2/ChangeLog:

            PR modula2/109810
            * gm2-compiler/M2ALU.mod (ConvertConstToType): Use
            PrepareCopyString in place of DoCopyString.
            * gm2-compiler/M2GenGCC.def (DoCopyString): Rename to ...
            (PrepareCopyString): ... this.
            * gm2-compiler/M2GenGCC.mod (CodeStatement): Call CodeReturnValue
            with a single parameter.  Call CodeXIndr with a single parameter.
            (CodeReturnValue): Remove parameters and replace with a single
            quadno.  Reimplement using PrepareCopyString.  Issue error
            if the string exceeds designator space.
            (DoCopyString): Reimplement and rename to ...
            (PrepareCopyString): ... this.
            (CodeXIndr): Remove parameters and replace with a single
            quadno.  Reimplement using PrepareCopyString.  Issue error
            if the string exceeds designator space.
            (CodeBecomes): Remove parameters and replace with a single
            quadno.  Reimplement using PrepareCopyString.  Issue error
            if the string exceeds designator space.
            * gm2-compiler/M2Quads.def (BuildReturn): Rename parameter to
            tokreturn.
            * gm2-compiler/M2Quads.mod (BuildReturn): Rename parameter to
            tokreturn.  Rename tokno to tokcombined.

    gcc/testsuite/ChangeLog:

            PR modula2/109810
            * gm2/pim/fail/highice.mod: New test.

    Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>

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

* [Bug modula2/109810] String literal exceeding array causes ICE
  2023-05-11 11:48 [Bug modula2/109810] New: String literal exceeding array causes ICE gaius at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2023-05-11 23:19 ` cvs-commit at gcc dot gnu.org
@ 2023-05-11 23:21 ` gaius at gcc dot gnu.org
  2023-07-28 18:28 ` cvs-commit at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-05-11 23:21 UTC (permalink / raw)
  To: gcc-bugs

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

Gaius Mulley <gaius at gcc dot gnu.org> changed:

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

--- Comment #6 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Closing now that the patch has been applied.

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

* [Bug modula2/109810] String literal exceeding array causes ICE
  2023-05-11 11:48 [Bug modula2/109810] New: String literal exceeding array causes ICE gaius at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2023-05-11 23:21 ` gaius at gcc dot gnu.org
@ 2023-07-28 18:28 ` cvs-commit at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-28 18:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Gaius Mulley
<gaius@gcc.gnu.org>:

https://gcc.gnu.org/g:52405b14b7e6a8d13ac53525a341ebfd27ef67cc

commit r13-7633-g52405b14b7e6a8d13ac53525a341ebfd27ef67cc
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date:   Fri Jul 28 19:27:18 2023 +0100

    PR modula2/109810 ICE fix when an array is assigned by a larger string

    This patch fixes an ICE when an array variable is assigned with
    a string which exceeds the array size.  It improves the accuracy
    of the virtual token used to indicate the error message.

    gcc/m2/ChangeLog:

            PR modula2/109810
            * gm2-compiler/M2ALU.mod (ConvertConstToType): Use
            PrepareCopyString in place of DoCopyString.
            * gm2-compiler/M2GenGCC.def (DoCopyString): Rename to ...
            (PrepareCopyString): ... this.
            * gm2-compiler/M2GenGCC.mod (CodeStatement): Call CodeReturnValue
            with a single parameter.  Call CodeXIndr with a single parameter.
            (CodeReturnValue): Remove parameters and replace with a single
            quadno.  Reimplement using PrepareCopyString.  Issue error
            if the string exceeds designator space.
            (DoCopyString): Reimplement and rename to ...
            (PrepareCopyString): ... this.
            (CodeXIndr): Remove parameters and replace with a single
            quadno.  Reimplement using PrepareCopyString.  Issue error
            if the string exceeds designator space.
            (CodeBecomes): Remove parameters and replace with a single
            quadno.  Reimplement using PrepareCopyString.  Issue error
            if the string exceeds designator space.
            * gm2-compiler/M2Quads.def (BuildReturn): Rename parameter to
            tokreturn.
            * gm2-compiler/M2Quads.mod (BuildReturn): Rename parameter to
            tokreturn.  Rename tokno to tokcombined.

    gcc/testsuite/ChangeLog:

            PR modula2/109810
            * gm2/pim/fail/highice.mod: New test.

    (cherry picked from commit c787f593e62869ae0b230949b4791f4f3a26e50e)

    Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>

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

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

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-11 11:48 [Bug modula2/109810] New: String literal exceeding array causes ICE gaius at gcc dot gnu.org
2023-05-11 11:49 ` [Bug modula2/109810] " gaius at gcc dot gnu.org
2023-05-11 11:52 ` gaius at gcc dot gnu.org
2023-05-11 22:06 ` gaius at gcc dot gnu.org
2023-05-11 22:08 ` gaius at gcc dot gnu.org
2023-05-11 23:19 ` cvs-commit at gcc dot gnu.org
2023-05-11 23:21 ` gaius at gcc dot gnu.org
2023-07-28 18:28 ` cvs-commit 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).