42School / norminette

Official 42 norminette
MIT License
926 stars 138 forks source link

detects DECL_ASSIGN_LINE on const pointers to functions #472

Open c-couble opened 8 months ago

c-couble commented 8 months ago

Describe the bug DECL_ASSIGN_LINE on const variable

Erroneous code Please use markdown to send the code here.

#include <stddef.h>
#include <stdlib.h>

int     main(void)
{
        void *(*const   f)(size_t) = malloc;
}
main.c: Error!
Error: INVALID_HEADER       (line:   1, col:   1):      Missing or invalid 42 header
Error: DECL_ASSIGN_LINE     (line:   6, col:  32):      Declaration and assignation on a single line

Additional infos

Additional context f is a const variable and it should be possible to declare and assign it on the same line.

Lilneo786 commented 8 months ago
#include <stddef.h>
#include <stdlib.h>

int main(void)
{
    void *(*const f)(size_t) = &malloc; // Assign the address of the malloc function
    return 0;
}