Menu

typedef

2020-04-04
2020-04-07
  • Daniel Marjamäki

    Cppcheck has problems with this code and I have the feeling that we do not simplify it properly:

    #include <utility>
    
    typedef unsigned char a4[4];
    
    int
    main ()
    {
      a4 a4obj;
      a4 &&  a4_rref = std::move(a4obj);
      a4* a4p = &(a4obj);
      a4*&& a4p_rref = std::move(a4p);
    
      return 0;
    }
    

    What is the corresponding code without using a typedef?

     
  • Paul Fultz

    Paul Fultz - 2020-04-04

    This compiles for me:

    #include <utility>
    
    int main()
    {
        unsigned char a4obj[4];
        unsigned char (&&a4_rref)[4] = std ::move(a4obj);
        unsigned char(*a4p)[4];
        a4p = &(a4obj);
        unsigned char (*&&a4p_rref)[4] = std ::move(a4p);
    
        return 0;
    }
    

    It also doesn't crash in cppcheck either.

     
  • Daniel Marjamäki

    Thanks! I'll try to output that in Tokenizer::simplifyTypedef.

     

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.