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

False positive -Wreturn-type for bitfields #52666

Open
marxin opened this issue Dec 13, 2021 · 1 comment
Open

False positive -Wreturn-type for bitfields #52666

marxin opened this issue Dec 13, 2021 · 1 comment
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer

Comments

@marxin
Copy link
Contributor

marxin commented Dec 13, 2021

The following test-case is wrongly marked with -Wreturn-type:

struct A
{
  unsigned int val: 1;
};

int foo(struct A *a)
{
  switch (a->val)
  {
    case 0:
      return 123;
    case 1:
      return 456;
  }
}
$ clang unreachable.c  -Werror=return-type -c
unreachable.c:15:1: error: non-void function does not return a value in all control paths [-Werror,-Wreturn-type]
}
^
1 error generated.

Note GCC accepts the code:

gcc unreachable.c  -Werror=return-type -c
@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" and removed new issue labels Jan 15, 2022
@llvmbot
Copy link
Collaborator

llvmbot commented Jan 15, 2022

@llvm/issue-subscribers-clang-frontend

@Quuxplusone Quuxplusone added clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer and removed clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer
Projects
None yet
Development

No branches or pull requests

4 participants