Menu

internalAstError with typeof/decltype

2022-02-10
2022-02-10
  • Tobias Mark

    Tobias Mark - 2022-02-10

    Hi,
    using cppcheck 2.6. I can't remember seeing this before maybe it's an regression.
    Example:

    #include <stdlib.h>
    struct Foo {
        char *foo;
        int len;
    };
    int main(int argc, char *argv[])
    {
        Foo bar;
        bar.foo = (typeof(bar.foo))calloc(bar.len, sizeof(*bar.foo));
        bar.foo = (decltype(bar.foo))calloc(bar.len, sizeof(*bar.foo));
    }
    

    =>

    test.c:9:23: error: Syntax Error: AST broken, 'bar' doesn't have a parent. [internalAstError]
        bar.foo = (typeof(bar.foo))calloc(bar.len, sizeof(*bar.foo));
    

    Note that it works if using simple vars instead of the struct.

     
  • CHR

    CHR - 2022-02-10

    Thanks for reporting, this is probably covered by https://trac.cppcheck.net/ticket/10739
    I have added your example to that ticket.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.