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

[CN] misleading error message concerning undefined struct arguments #888

Open
peterohanley opened this issue Feb 25, 2025 · 1 comment
Open
Labels
cn ui/ux Issue with presentation or user experience

Comments

@peterohanley
Copy link

#437 also concerns undefined structs but here cn permits them, then gives a misleading message about A!=A.

struct y {
    void* y;
};
void foo(struct s *a)
{
}
void bar(void)
{
    struct y a = {0};
    foo((struct s*)&a);
}
% cn verify incompatible.c
incompatible.c:14:9: error: constraint violation: incompatible pointer types passing 'struct s*' to parameter of type 'struct s*'
    foo((struct s*)&a);
        ^~~~~~~~~~~~~ 
@peterohanley
Copy link
Author

If the structure is declared out of order with the struct this error will still happen and print the same message but now one s is the declared one and the other s is the undeclared one

% cat incompatible.c 
void foo(struct s *a)
{}
struct s {
    void* y;
};
void bar(void)
{
    struct s a = {0};
    foo((struct s*)&a);
}
% cn verify incompatible.c
incompatible.c:9:9: error: constraint violation: incompatible pointer types passing 'struct s*' to parameter of type 'struct s*'
    foo((struct s*)&a);
        ^~~~~~~~~~~~~ 

@dc-mak dc-mak added cn ui/ux Issue with presentation or user experience labels Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cn ui/ux Issue with presentation or user experience
Projects
None yet
Development

No branches or pull requests

2 participants