public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "gaius at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug modula2/114617] New: gm2 is unable to resolve const expression using relative operators ICE
Date: Sat, 06 Apr 2024 02:53:54 +0000	[thread overview]
Message-ID: <bug-114617-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 114617
           Summary: gm2 is unable to resolve const expression using
                    relative operators 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: ---

For example, it appears to occur if a constant expression has a relop.  The
result of the relop is stored in a variable and is not resolved at compile
time.


$ gm2 -g -c BasicFileSys.mod
-I../../../../Sandpit/gm2-outside-tree-tests/build/source/m2pp/src/ 
terminate called after throwing an instance of 'unsigned int'
cc1gm2: internal compiler error: Aborted
0x178a0e3 crash_signal
        ../../gcc/toplev.cc:319
0xffff8f590990 __pthread_kill_implementation
        ./nptl/pthread_kill.c:44
0xffff8f54a76b __GI_raise
        ../sysdeps/posix/raise.c:26
0xffff8f5374bb __GI_abort
        ./stdlib/abort.c:79
0xf1a64f InvokeHandler
        m2/gm2-libs-boot/RTExceptions.c:484
0xf1b1ff RTExceptions_Raise
        m2/gm2-libs-boot/RTExceptions.c:946
0xf1ac33 invalidloc
        m2/gm2-libs-boot/RTExceptions.c:755
0xf211a3 sigbusDespatcher
        ../../gcc/m2/gm2-libs-ch/SysExceptions.c:125
0x11fce74 fold(tree_node*)
        ../../gcc/fold-const.cc:13798
0xde8bd7 m2convert_BuildConvert
        ../../gcc/m2/gm2-gcc/m2convert.cc:439
0xdf1f33 m2expr_BuildIndirect
        ../../gcc/m2/gm2-gcc/m2expr.cc:3520
0xe5802b CodeXIndr
        m2/gm2-compiler-boot/M2GenGCC.c:9350
0xe47cd3 CodeStatement
        m2/gm2-compiler-boot/M2GenGCC.c:2062
0xe58177 M2GenGCC_ConvertQuadsToTree
        m2/gm2-compiler-boot/M2GenGCC.c:9380
0xe939af M2Scope_ForeachScopeBlockDo2
        m2/gm2-compiler-boot/M2Scope.c:675
0xe33783 M2Code_CodeBlock
        m2/gm2-compiler-boot/M2Code.c:529
0xe33027 DoCodeBlock
        m2/gm2-compiler-boot/M2Code.c:292
0xe336b3 M2Code_Code
        m2/gm2-compiler-boot/M2Code.c:467
0xe33c53 Compile
        m2/gm2-compiler-boot/M2Comp.c:469
0xe359a3 M2Comp_compile
        m2/gm2-compiler-boot/M2Comp.c:1592


The variable used to contain the result of the relop constant expression can be
seen in:

MODULE constbool3 ;


CONST
   AddressableBits = 32 ;
   MaxBits         = 16 ;

   BitsInUse = ORD(AddressableBits > MaxBits) * MaxBits + ORD(AddressableBits
<= MaxBits) * AddressableBits;

BEGIN

END constbool3.

$ gm2 -fiso constbool3.mod 
constbool3.mod:8:36: error: In program module 'constbool3': the procedure
function 'ORD' is being called from within a constant expression and therefore
the parameter must be a constant, seen a expression
    8 |    BitsInUse = ORD(AddressableBits > MaxBits) * MaxBits +
ORD(AddressableBits <= MaxBits) * AddressableBits;
      |                    ~~~~~~~~~~~~~~~~^~~~~~~~~
constbool3.mod:8:79: error: the procedure function 'ORD' is being called from
within a constant expression and therefore the parameter must be a constant,
seen a expression
    8 |    BitsInUse = ORD(AddressableBits > MaxBits) * MaxBits +
ORD(AddressableBits <= MaxBits) * AddressableBits;
      |                                                              
~~~~~~~~~~~~~~~~^~~~~~~~~~
constbool3.mod:8:14: error: in assignment, cannot assign a variable to a
constant 'BitsInUse'
    8 |    BitsInUse = ORD(AddressableBits > MaxBits) * MaxBits +
ORD(AddressableBits <= MaxBits) * AddressableBits;
      |   
~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
constbool3.mod:8:4: error: designator 'BitsInUse' is declared as a CONST
    8 |    BitsInUse = ORD(AddressableBits > MaxBits) * MaxBits +
ORD(AddressableBits <= MaxBits) * AddressableBits;
      |    ^~~~~~~~~

             reply	other threads:[~2024-04-06  2:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-06  2:53 gaius at gcc dot gnu.org [this message]
2024-04-06  2:54 ` [Bug modula2/114617] " gaius at gcc dot gnu.org
2024-04-06  3:02 ` gaius at gcc dot gnu.org
2024-04-06  8:46 ` gaius at gcc dot gnu.org
2024-04-06 22:46 ` cvs-commit at gcc dot gnu.org
2024-04-06 22:52 ` gaius at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-114617-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).