public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug modula2/114617] New: gm2 is unable to resolve const expression using relative operators ICE
@ 2024-04-06  2:53 gaius at gcc dot gnu.org
  2024-04-06  2:54 ` [Bug modula2/114617] " gaius at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: gaius at gcc dot gnu.org @ 2024-04-06  2:53 UTC (permalink / raw)
  To: gcc-bugs

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;
      |    ^~~~~~~~~

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

end of thread, other threads:[~2024-04-06 22:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-06  2:53 [Bug modula2/114617] New: gm2 is unable to resolve const expression using relative operators ICE gaius at gcc dot gnu.org
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

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).