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

Compiler warning about function call in brent's method #169

Open
kbroman opened this issue Jun 29, 2020 · 5 comments
Open

Compiler warning about function call in brent's method #169

kbroman opened this issue Jun 29, 2020 · 5 comments
Labels

Comments

@kbroman
Copy link
Member

kbroman commented Jun 29, 2020

Compiler on CRAN is giving this warning:

brent_fmin.cpp:156:10: runtime error: call to function negLL(double, calcLL_args*) through pointer
     to incorrect function type 'double (*)(double, void *)'
@kbroman kbroman added the bug label Jun 29, 2020
@kbroman
Copy link
Member Author

kbroman commented Jul 10, 2020

This seems identical to what's in optimize.c in the R stats package.

@kbroman kbroman closed this as completed Oct 7, 2021
@kbroman
Copy link
Member Author

kbroman commented Oct 7, 2021

I'm going to close this and not fix it; CRAN seems to be allowing the warning.

kbroman added a commit to kbroman/qtl2 that referenced this issue Oct 7, 2021
@kbroman kbroman reopened this Oct 7, 2021
@kbroman
Copy link
Member Author

kbroman commented Oct 7, 2021

I think I can add a function attribute to avoid this warning, and so I’ll re-open the issue.
See clang documentation.

@kbroman
Copy link
Member Author

kbroman commented Oct 7, 2021

Seems like the following docker container is just want I need for testing: rocker/r-devel-ubsan-clang

(Seems like you need to re-build it, and that you need to replace llvm-7 with llvm-12 in the Dockerfile.)

@kbroman
Copy link
Member Author

kbroman commented Oct 8, 2021

Ugh; I can't figure out the appropriate way to use this __attribute__((no_sanitize("undefined"))) business. Since I'm only making one call to brent_fmin(), I might just hard-code the function arguments.

kbroman added a commit to kbroman/qtl2 that referenced this issue Oct 8, 2021
- brent_fmin takes a general function with a void * for args, but apparently
  this is "undefined behavior" and CRAN says I need to fix the warning.

- There seems to be a way to suppress the warning, but I can't figure out
  how to do it.
  <https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#disabling-instrumentation-with-attribute-no-sanitize-undefined>

- So here I'm using the ugly approach, of just hard-coding particular
  function arguments, since I just use brent_fmin() a single time.
kbroman added a commit to kbroman/qtl2 that referenced this issue Oct 8, 2021
- brent_fmin takes a general function with a void * for args, but apparently
  this is "undefined behavior" and CRAN says I need to fix the warning.

- There seems to be a way to suppress the warning, but I can't figure out
  how to do it.
  <https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#disabling-instrumentation-with-attribute-no-sanitize-undefined>

- So here I'm using the ugly approach, of just hard-coding particular
  function arguments, since I just use brent_fmin() a single time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant