Skip to content

[flang] Incorrect warning message about default integer kind #153202

@DanielCChen

Description

@DanielCChen

Consider the following reducer

  PROGRAM  main
  IMPLICIT NONE

  INTEGER(1), PARAMETER :: I1Max=127

  INTEGER(2), PARAMETER :: I2Max=32767

  print*, I2Max+I1Max-1          

  END

Flang complains:

./t.f:8:12: warning: INTEGER(2) addition overflowed [-Wfolding-exception]
    print*, (I2Max+I1Max-1)
             ^^^^^^^^^^^

The result integer kind of the expression should be default integer kind, which is 4.
The error message seems incorrect, which also caused incorrect run result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    flang:frontendquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions