Menu

#156 CC failed parsing the char (*varname)[7]; (a pointer to an array of characters) definition

Undefined
open
nobody
Bug_Report
2015-09-08
2015-04-15
raynebc
No

I'm finding that when I attempt to use find declaration on a particular variable (a pointer to an array of characters), it defeats CodeBlocks which claims the variable is not found. It's able to find other variables just fine, but the one in question is defined as:

char (*varname)[7];

And is assigned memory with:

varname = malloc(7 * sizeof(char) * tracks);

Where "tracks" is an unsigned long int that is otherwise irrelevant to this issue. Unless I'm mistaken, this is the correct syntax to use for defining this type of variable, as "char *varname[7]" is supposed to instead refer to an array of pointers.

Discussion

  • raynebc

    raynebc - 2015-04-15

    I forgot to mention this happens in the latest nightly build (April 12, 2015), as well as several older nightlies that I tried.

     
  • raynebc

    raynebc - 2015-04-15

    Additionally, since this is probably a good time to mention it, I often find that I have to use "find declaration" multiple times to jump to its declaration. It will say the variable is not found and then when I've tried enough times it will then find it and will display the declaration. This happens for very simplistic variables and macro definitions, the only thing that makes them at all complicated is that they generally are declared in a header file other than the source file I have open.

     

    Last edit: raynebc 2015-04-15
  • Teodor Petrov

    Teodor Petrov - 2015-04-15

    Can you post minimal self-contained project and exact steps to reproduce the problem?

     
  • raynebc

    raynebc - 2015-04-15

    I'm attaching a simple source file that easily reproduces the bug I mentioned in the first post. Just open it, right click on the buffer variable name in line 8 and select "Find declaration of: 'buffer'". When I do that, I immediately get a "Not found: buffer" dialog notice.

    About the other bug I mentioned with "Find declaration", I tried to create a simple project of two source files and one header file but couldn't reliably reproduce this behavior. It may only be prone to happening on larger projects. If anybody wanted to investigate, the project that I work on that triggered the problem is here:
    http://code.google.com/p/editor-on-fire/

     
  • ollydbg

    ollydbg - 2015-04-16
    • labels: --> CodeCompletion
     
  • ollydbg

    ollydbg - 2015-09-08
    • summary: Variable declaration defeats "Find declaration" function --> CC failed parsing the char (*varname)[7]; (a pointer to an array of characters) definition
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,8 +1,9 @@
     I'm finding that when I attempt to use find declaration on a particular variable (a pointer to an array of characters), it defeats CodeBlocks which claims the variable is not found.  It's able to find other variables just fine, but the one in question is defined as:
    
    -char (*varname)[7];
    +    char (*varname)[7];
    
     And is assigned memory with:
    -varname = malloc(7 * sizeof(char) * tracks);
    +
    +    varname = malloc(7 * sizeof(char) * tracks);
    
     Where "tracks" is an unsigned long int that is otherwise irrelevant to this issue.  Unless I'm mistaken, this is the correct syntax to use for defining this type of variable, as "char *varname[7]" is supposed to instead refer to an array of pointers.
    
     
  • ollydbg

    ollydbg - 2015-09-08

    I can confirm this bug. I also change the title

     

Log in to post a comment.