Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report] Array arguments will be parsed to "forward declaration" in a function #7

Open
FanWuUCL opened this issue Feb 25, 2016 · 0 comments
Labels

Comments

@FanWuUCL
Copy link
Collaborator

Bug description:
Though normally I don't write a function in this way, but the program I use for Mutation Testing study used this way:
static void func( sym, x )
char sym[];
int x;
{}
In this case, after Milu parse the code, the array argument 'sym' will be interpreted as a forward declaration but not an actual argument.

How to recreate the bug:

  1. Write the following code to a file, say "bug.c":

include<stdlib.h>

static void func( sym, x )
char sym[];
int x;
{
if(x==0);
}

void main(int argc, char** argv){
func(0, 0);
}
2. Run Milu to generate mutants on "bug.c", with the default set of operators, but add option "--debug=src":
$ path\to\milu --debug=src bug.c
3. The output will be the original code being parsed and printed without any modification:

include<stdlib.h>

static void func ( char sym [ ] ; int x )
{
if ( x == 0 ) ;

}

;
void main ( int argc , char * * argv )
{
func ( 0 , 0 ) ;
}
4. Not easy to spot, but in the function declaration of 'func', there is a ';' instead of ',' between the two arguments 'sym' and 'x', so that the first argument is interpreted as a forward declaration. This will cause the compiler to complain that the arguments don't match in any of the invocations of this function.

Temporary Solution for users:
No idea. Avoid this kind of way to declare a function maybe?

@FanWuUCL FanWuUCL added the bug label Feb 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant