ClangSharp icon indicating copy to clipboard operation
ClangSharp copied to clipboard

DivideByZeroException in GetTypeSize

Open andrew-boyarshin opened this issue 3 years ago • 1 comments

public override Task NestedDeclarationTest()
{
    var inputContents = @"struct CustomNativeNew {};

struct CustomNativeNewNested
{
    CustomNativeNew Nested;
};
";

    var expectedOutputContents = @"namespace ClangSharp.Test
{
    public partial struct CustomNativeNew
    {
    }

    public partial struct CustomNativeNewNested
    {
        public CustomNativeNew Nested;
    }
}
";

    return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents);
}

Found after fixing #223 (actually, first uncovered when working on next-generation SharpGen based on ClangSharp).

Test origin.

image image

andrew-boyarshin avatar Mar 29 '21 13:03 andrew-boyarshin

This likely means that an unsupported type declaration was also encountered and the size/alignment for it was not changed from the default.

The else block that adds the diagnostic should likely set the alignment to the default alignment (4/8) if nothing else has been set to avoid this issue.

tannergooding avatar Mar 29 '21 15:03 tannergooding

This one isn't repro'ing anymore. I believe I fixed it a while back when I adjusted the handling to use -1 as the default.

tannergooding avatar Sep 18 '22 18:09 tannergooding