8

I just had the most confusing error ever where clang ast randomly replaced classes with just int in type signatures

...wat? I guess the class only has one int field so maybe there's a cpp rule that requires replacing classes with their only field or something?

But when I add other fields it doesn't change. Even if the class has no int fields, it's still replaced by int in the ast

....

Yeah turns out I had the definitions in the wrong order and clang just uses int for unknown types instead of... you know maybe raising a fucking error

Thanks clang...

Comments
  • 4
    @12bitfloat I'm pretty sure that's because of old C rules assuming things are int. Someone please double-check though
  • 2
    @BordedDev If there's no type, the default is int I believe

    But if you actually have a parameter of type ExampleBase*... can you just replace that with int*???
  • 1
    Still very often the same in more modern languages.

    Just write
    let x =

    And leave the rest open. It is of course caught, but the LSP already spits out a guess. Mostly strings for some reason
  • 0
    Please show how this happens in code. This is very interesting.
  • 0
    @Demolishun This isn't in code really, it's when you run `clang -Xclang -ast-dump=json -fsyntax-only` to get a json dump of the ast
  • 0
    @12bitfloat oh. I thought it was transforming types or something.
  • 2
    @Demolishun Well, it is... in the ast at least
  • 3
    "in the ast", sometimes words line up uncomfortably...
  • 1
  • 4
    So I guess the TLDR of your post is "pain in the ast".
  • 3
    At least use a dedicated placeholder, like int_by_default
  • 2
    Cool people use tcc as their compiler. Edit: oh, cpp. Cool people use gcc as their compiler.
  • 2
    @retoor llvm master race!
  • 2
    @12bitfloat haha so is clang worth it ?
  • 2
    @AvatarOfKaine Clang is good, this was just a very niche thing
  • 2
    pretty soon people will be snorting whip cream and putting hats up their asses trying something new to see if it works since everything else is the province of stupid people who lie.
  • 2
    @AvatarOfKaine objects in a computer program are hallucination of the programmer. Once it is machine code there is no concept of objects anymore. It becomes pointers, data, and instructions. If the code generates correctly it works and does what you want.
  • 2
    @Demolishun I think that that it's the reason why many people do not get computers. They just see it as smth not real. Nothing wrong with it tho, I have the same with people who blow leafs for a living. So useless.
Add Comment