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

space after pointer, but the variable isn't a pointer #441

Open
andreyvdl opened this issue Oct 9, 2023 · 1 comment
Open

space after pointer, but the variable isn't a pointer #441

andreyvdl opened this issue Oct 9, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@andreyvdl
Copy link

andreyvdl commented Oct 9, 2023

Describe the bug

The norminette detects a line with multiplication as a pointer being de-referenced

Erroneous code

float	cost_y_ray_distance(float *x, float *y, float tangent, float rayAng)
{
	float	off[2];
	float	ray[2];

	if (rayAng > M_PI && rayAng < 2 * M_PI)
	{
		ray[H] = ((int)(g_player_y / SIZE) * SIZE) - 0.0001;
		ray[W] = (g_player_y - ray[H]) * tangent + g_player_x;
		off[H] = -SIZE;
		off[W] = -off[H] * tangent;
	}
	if (rayAng < M_PI && rayAng < 3 * M_PI / 2)
	{
		ray[H] = ((int)(g_player_y / SIZE) * SIZE) + SIZE;
		ray[W] = (g_player_y - ray[H]) * tangent + g_player_x;
		off[H] = SIZE;
		off[W] = -off[H] * tangent;
	}
	if (rayAng == 0 || rayAng == (float)M_PI)
	{
		ray[W] = g_player_x;
		ray[H] = g_player_y;
	}
	update_distance(x, y, ray, off);
	return (pythagoras(g_player_x, g_player_y, ray[W], ray[H]));
}

Additional infos

  • OS: Ubuntu 20.04.6 LTS
  • python3 --version: 3.8.10
  • norminette -v: 3.3.52

Additional context

this is how the norminette is detecting

cub.c - IsAssignation In "ControlStructure" from "Function" line 196":
		<TAB> <TAB> <IDENTIFIER=ray> <LBRACKET> <IDENTIFIER=H> <RBRACKET> <SPACE> <ASSIGN> <SPACE> <LPARENTHESIS> <LPARENTHESIS> <INT> <RPARENTHESIS> <LPARENTHESIS> <IDENTIFIER=g_player_y> <SPACE> <DIV> <SPACE> <IDENTIFIER=SIZE> <RPARENTHESIS> <SPACE> <MULT> <SPACE> <IDENTIFIER=SIZE> <RPARENTHESIS> <SPACE> <MINUS> <SPACE> <CONSTANT=0.0001> <SEMI_COLON> <NEWLINE>
...
Error: SPC_AFTER_POINTER    (line: 196, col:  44):	space after pointer
Error: SPC_AFTER_POINTER    (line: 203, col:  44):	space after pointer
Error: TOO_MANY_FUNCS       (line: 217, col:   1):	Too many functions in file
Error: SPC_AFTER_POINTER    (line: 224, col:  44):	space after pointer
Error: SPC_AFTER_POINTER    (line: 231, col:  44):	space after pointer

edit: i pasted the wrong lines

@matthieu42Network matthieu42Network added the bug Something isn't working label Oct 10, 2023
@andreyvdl
Copy link
Author

andreyvdl commented Oct 19, 2023

For more context a friend of mine tried some way to solve this:

ray[H] = (int)g_player_y / SIZE * SIZE - 0.0001;
ray[H] = ((int)g_player_y / SIZE * SIZE) - 0.0001;
ray[H] = ((int)((g_player_y / SIZE)) * SIZE) - 0.0001;

All these solutions make the norm stop recognizing * SIZE as a pointer.
I choose the third because the global is a double and i need to divide the value by SIZE before converting to int.

edit: typo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants