[clang] [clang][ASTImporter] Fix possible crash "given incorrect InsertPos for specialization". (PR #89887)

Qizhi Hu via cfe-commits cfe-commits at lists.llvm.org
Sat May 25 06:09:39 PDT 2024


jcsxky wrote:

> > Could you please show your commands which reproduced this crash? I tested locally with the following commands and it runs OK.
> > ```c++
> > clang++ -cc1 -std=c++17 -emit-pch -o test.cpp.ast test.cpp
> > clang++ -cc1 -x c++ -ast-merge test.cpp.ast  /dev/null -ast-dump
> > ```
> 
> That code is only an example, it differs not much of the real code that caused the crash. But it is not enough to use this code for the problem reproduction. This code can be used to get the case when the specialization list is changed before the insertion, but even then no crash happens:
> 
> ```c++
> namespace N {
> template <unsigned X>
> int B = B<X - 1> + B<X - 2>;
> template <>
> int B<0> = 0;
> template <>
> int B<1> = 1;
> }
> int A = N::B<5>;
> ```
> 
> With clang version 18.1.6 the original crash does not occur any more. The "original crash" was reproduced on specific source files of project "contour". Probably I can attach the files and command, but some changes can be required to make it work.

Could you please show me how to reproduce the crash in detail if possible? Then I can debug this issue in my spare time.

https://github.com/llvm/llvm-project/pull/89887


More information about the cfe-commits mailing list