Error parsing CXXDeductionGuide
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
Research direction
Start with the C++17 reproduction in the issue, focusing on the CXXDeductionGuide diagnostic and the resulting parser crash. Then investigate the separate precompiled-header case involving and the undeclared assert error. Done means the deduction-guide input no longer crashes parsing and the precompiled-header behavior is understood or corrected.
Written by the indexing model from the issue text.
Description
Consider:
using CppSharp;
using CppSharp.AST;
using CppSharp.Parser;
class Program
{
class TestLibrary : ILibrary
{
public void SetupPasses(Driver driver)
{
}
public void Preprocess(Driver driver, ASTContext ctx)
{
}
public void Postprocess(Driver driver, ASTContext ctx)
{
}
public void Setup(Driver driver)
{
DriverOptions driverOptions = driver.Options;
ParserOptions parserOptions = driver.ParserOptions;
parserOptions.LanguageVersion = LanguageVersion.CPP17;
parserOptions.AddCompilationOptions("-frtti");
driverOptions.Quiet = false;
driverOptions.DryRun = true;
driverOptions.OutputDir = Directory.GetCurrentDirectory();
var module = driverOptions.AddModule("test");
string temp = Path.GetTempFileName();
File.WriteAllText(temp, @"
template<class T>
struct container
{
container(T t) {}
template<class Iter>
container(Iter beg, Iter end);
};
// additional deduction guide
template<class Iter>
container(Iter b, Iter e) -> container<typename std::iterator_traits<Iter>::value_type>;
");
module.Headers.Add(temp);
}
}
static void Main(string[] args)
{
ConsoleDriver.Run(new TestLibrary());
}
}
Output:
Parsing libraries...
Parsing code...
Unhandled declaration kind: CXXDeductionGuide
C:\Users\user\AppData\Local\Temp\tmp6CC2.tmp (line 5)
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Repeat 2 times:
--------------------------------
at CppSharp.Parser.ClangParser+__Internal.ParseHeader(IntPtr)
--------------------------------
at CppSharp.Parser.ClangParser.ParseHeader(CppSharp.Parser.CppParserOptions)
at CppSharp.ClangParser.ParseSourceFiles(System.Collections.Generic.IEnumerable`1<System.String>, CppSharp.Parser.ParserOptions)
at CppSharp.Driver.ParseCode()
at CppSharp.ConsoleDriver.Run(CppSharp.ILibrary)
at Program.Main(System.String[])
Second question:
How to include a precompiled header?
Because when <cassert> is included in a precompiled header I am getting:
error: use of undeclared identifier 'assert'
CppSharp has encountered an error while parsing code.
- Dominant language
- C#
- Stars
- 3.4k
- Forks
- 541
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from mono/CppSharp
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
How to get started Open
Difficulty 3/5 1-2 days Newbie friendliness 38/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15108 · 1 comment ·
-
area/docs-content Bug pulumi/docs
Difficulty 1/5 1-3 hours Newbie friendliness 94/100
-
agentic-workflows untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 76/100