Skip to content

Conversation

@DavidSpickett
Copy link
Collaborator

If the size of the other Interval was 0, (that.size_ - 1) would wrap below zero.

I've fixed this so that a zero size interval A is within interval B if the start of A is within B. There's a few ways you could handle zero sized intervals in theory but this one passes all tests so I assume it's the intention.

This fixes the following tests when ubsan is enabled:
Flang :: Lower/OpenMP/PFT/sections-pft.f90
Flang :: Lower/OpenMP/derived-type-allocatable.f90
Flang :: Lower/OpenMP/privatization-proc-ptr.f90
Flang :: Lower/OpenMP/sections.f90
Flang :: Parser/OpenMP/sections.f90
Flang :: Semantics/OpenMP/clause-validity01.f90
Flang :: Semantics/OpenMP/if-clause.f90
Flang :: Semantics/OpenMP/parallel-sections01.f90
Flang :: Semantics/OpenMP/private-assoc.f90

If the size of the other Interval was 0, (that.size_ - 1)
would wrap below zero.

I've fixed this so that a zero size interval A is within
interval B if the start of A is within B.

There's a few ways you could handle zero sized intervals
in theory but this one passes all tests so I assume it's
the intention.

This fixes the following tests when ubsan is enabled:
  Flang :: Lower/OpenMP/PFT/sections-pft.f90
  Flang :: Lower/OpenMP/derived-type-allocatable.f90
  Flang :: Lower/OpenMP/privatization-proc-ptr.f90
  Flang :: Lower/OpenMP/sections.f90
  Flang :: Parser/OpenMP/sections.f90
  Flang :: Semantics/OpenMP/clause-validity01.f90
  Flang :: Semantics/OpenMP/if-clause.f90
  Flang :: Semantics/OpenMP/parallel-sections01.f90
  Flang :: Semantics/OpenMP/private-assoc.f90
@llvmbot llvmbot added the flang Flang issues not falling into any other category label Jul 8, 2025
@DavidSpickett DavidSpickett requested review from DavidTruby and tblah July 8, 2025 11:02
Copy link
Member

@DavidTruby DavidTruby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks!

@DavidSpickett DavidSpickett merged commit 31786ee into llvm:main Jul 8, 2025
11 checks passed
@DavidSpickett DavidSpickett deleted the flang-contains branch July 8, 2025 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flang Flang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants