Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clang 18+ frontend crash on including a header file #85148

Open
Sid911 opened this issue Mar 13, 2024 · 6 comments
Open

Clang 18+ frontend crash on including a header file #85148

Sid911 opened this issue Mar 13, 2024 · 6 comments
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid] needs-reduction Large reproducer that should be reduced into a simpler form

Comments

@Sid911
Copy link

Sid911 commented Mar 13, 2024

This issue is related to tcbrindle/flux#174.
Initially tested on :

Ubuntu clang version 19.0.0 (++20240222031214+307409a8872f-1~exp1~20240222151237.1514)
Target: x86_64-pc-linux-gnu
Thread model: posix

Clang 19 backtrace can be accessed here with compiler explorer link to reproduce on clang 18 here

The flux maintainer did patch a workaround in the related PR to the issue by bypassing using the iterator altogether and using internal FLUX_FOR macro but I doubt this compiler behavior is acceptable. I also have experienced this before in last 3 weeks while including some other header library unfortunately my memory is vague about what I was doing so I won't be able to reproduce it.

@github-actions github-actions bot added the clang Clang issues not falling into any other category label Mar 13, 2024
@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" crash Prefer [crash-on-valid] or [crash-on-invalid] and removed clang Clang issues not falling into any other category labels Mar 13, 2024
@llvmbot
Copy link
Member

llvmbot commented Mar 13, 2024

@llvm/issue-subscribers-clang-frontend

Author: Siddharth Sinha (Sid911)

This issue is related to https://github.com/tcbrindle/flux/issues/174. Initially tested on : ``` Ubuntu clang version 19.0.0 (++20240222031214+307409a8872f-1~exp1~20240222151237.1514) Target: x86_64-pc-linux-gnu Thread model: posix ``` Clang 19 backtrace can be accessed [here](https://gist.github.com/Sid911/a76b694a6c69656a5fb9957a2dec2551#file-flux_clang19_stacktrace-txt) with compiler explorer link to reproduce on clang 18 [here](https://flux.godbolt.org/z/8e87j7oM6)

The flux maintainer did patch a workaround in the related PR to the issue by bypassing using the iterator altogether and using internal FLUX_FOR macro but I doubt this compiler behavior is acceptable. I also have experienced this before in last 3 weeks while including some other header library unfortunately my memory is vague about what I was doing so I won't be able to reproduce it.

@shafik shafik added the needs-reduction Large reproducer that should be reduced into a simpler form label Mar 14, 2024
@shafik
Copy link
Collaborator

shafik commented Mar 14, 2024

Maybe related: #70601

@shafik shafik added the confirmed Verified by a second party label Mar 14, 2024
@tcbrindle
Copy link

tcbrindle commented Mar 14, 2024

Another reproducer from the same library: https://flux.godbolt.org/z/P1PGPesoj (via tcbrindle/flux#179)

Interestingly, if we insert an explicit call to the flux::end function before the range-for loop, then compilation succeeds: https://flux.godbolt.org/z/zeK7x1K7W

Clang 16 and 17 compile the code correctly, so this looks to be a regression in 18.1

@tbaederr
Copy link
Contributor

With assertions: https://flux.godbolt.org/z/66Es3chYT

Looks like it's a SourceLocExpr where the PresumedLoc we compute in EvaluateInContext is just invalid.
Not sure if this should just fail or if this should be caught earlier.

@Endilll
Copy link
Contributor

Endilll commented Apr 2, 2024

One reduction of this seems to be fixed on post-18 trunk (https://godbolt.org/z/h3a8EPcq7):

template <typename>
concept sequence = true;

template <sequence S>
struct sequence_iterator {
  template <sequence SS>
  friend struct sequence_iterator;

  constexpr sequence_iterator(S) {}
};

constexpr sequence_iterator<int> end() {
  return sequence_iterator{0};
}

@zyn0217
Copy link
Contributor

zyn0217 commented Apr 3, 2024

One reduction of this seems to be fixed on post-18 trunk (https://godbolt.org/z/h3a8EPcq7):

template <typename>

concept sequence = true;



template <sequence S>

struct sequence_iterator {

  template <sequence SS>

  friend struct sequence_iterator;



  constexpr sequence_iterator(S) {}

};



constexpr sequence_iterator<int> end() {

  return sequence_iterator{0};

}

Yeah, the pattern looks like #86769 to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid] needs-reduction Large reproducer that should be reduced into a simpler form
Projects
None yet
Development

No branches or pull requests

8 participants