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

error: cast from pointer to smaller type 'int' loses information #624

Open
yurivict opened this issue Jan 12, 2023 · 1 comment · May be fixed by #675
Open

error: cast from pointer to smaller type 'int' loses information #624

yurivict opened this issue Jan 12, 2023 · 1 comment · May be fixed by #675

Comments

@yurivict
Copy link

yurivict commented Jan 12, 2023

src/annoymodule.cc:182:12: error: cast from pointer to smaller type 'int' loses information
    return (int) NULL;
           ^~~~~~~~~~

NULL can't be converted to integer because it is a pointer.

In fact, this function call and comparison are meaningless:

  if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i|s", (char**)kwlist, &f, &metric))
    return (int) NULL;
  return 0;

You can replace this code with return 0;.

clang-14
FreeBSD 13.1

@agcr
Copy link

agcr commented Dec 26, 2024

I've got the same error when building with clang-18 on FreeBSD 13.4.

The correct fix seems to be to return -1, see this discussion on initproc return value.

Also -1 is used in example from official documentation.

@agcr agcr linked a pull request Dec 26, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants