<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/112516>112516</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Clang front-end segmentation fault
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          zmochi
      </td>
    </tr>
</table>

<pre>
    Clang front-end crashes with a segmentation fault while processing C code.

The offending line is a `constexpr` very similar to the minimal example I attempted to write below.

I tried to reduce the preprocessed files with `creduce` and [creduce-clang-crash.py](https://github.com/llvm-mirror/clang/blob/master/utils/creduce-clang-crash.py) as suggested in [how to submit a bug](https://llvm.org/docs/HowToSubmitABug.html) but the script did not emit the listed files (I did notice the repository is deprecated but worth a shot). [This is the output of the script](https://github.com/user-attachments/files/17393782/creduce-clang-crash-output.txt). It seems like `creduce` itself crashed but I'm not sure.

Output of clang command causing the crash:
[clang-crash-output.txt](https://github.com/user-attachments/files/17394080/clang-crash-output.txt)
Crash report:
[clang-19-2024-10-16-130218.ips.txt](https://github.com/user-attachments/files/17394090/clang-19-2024-10-16-130218.ips.txt)
Preprocessed source:
[freelist_tests-4bf7f5.c.txt](https://github.com/user-attachments/files/17394122/freelist_tests-4bf7f5.c.txt)
Run script:
[freelist_tests-4bf7f5.sh.txt](https://github.com/user-attachments/files/17394130/freelist_tests-4bf7f5.sh.txt)

The actual source files are:
[freelist.c.txt](https://github.com/user-attachments/files/17394219/freelist.c.txt)
[freelist_tests.c.txt](https://github.com/user-attachments/files/17394262/freelist_tests.c.txt)
[freelist.h.txt](https://github.com/user-attachments/files/17394223/freelist.h.txt)

I tried to reproduce a minimal example with the following input which did not crash:
```c
#define min(a, b) ((a) < (b) ? (a) : (b))

struct min_st {
    int a;
};

void foo(struct min_st *st) {
 constexpr int bad_constexpr = min(10, st->a);
}
```
</pre>
<img width="1px" height="1px" al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