Skip to content

Fix unused variable warnings by using n_mulhi#2656

Merged
fredrik-johansson merged 1 commit intoflintlib:mainfrom
user202729:umulhigh-fix-warnings
May 4, 2026
Merged

Fix unused variable warnings by using n_mulhi#2656
fredrik-johansson merged 1 commit intoflintlib:mainfrom
user202729:umulhigh-fix-warnings

Conversation

@user202729
Copy link
Copy Markdown
Contributor

@user202729 user202729 commented May 1, 2026

Fix #2655

The transformations are clearly safe, and the warnings are gone on my machine.

@vneiger
Copy link
Copy Markdown
Collaborator

vneiger commented May 3, 2026

To better understand what this solves and why a solution is needed, could you please give more details on the context in which these pieces of code triggered this warning? Is this when compiling flint itself? If yes, on what kind of system/compiler/cpu?

Some comments:

  • There is already a function n_mulhi in ulong_extras.h, which has the same behaviour as your macro umulhigh_pmm. It's not clear to me that there is a good reason for both to co-exist.
  • There is a macro FLINT_SET_BUT_UNUSED in flint.h, which should suppress this specific warning (but maybe not not for all possible configurations of compiler/system/etc).

@albinahlback
Copy link
Copy Markdown
Collaborator

I believe it is being triggered for at least all Clang compilers. The only reason why some people never see these warnings is because we force GCC to use assembly, where GCC assumes that the variables are being used.

@user202729 user202729 force-pushed the umulhigh-fix-warnings branch from 67e3da4 to 2421b9c Compare May 4, 2026 08:43
@user202729 user202729 force-pushed the umulhigh-fix-warnings branch from 2421b9c to d9d1407 Compare May 4, 2026 08:46
@user202729
Copy link
Copy Markdown
Contributor Author

  • I didn't know about n_mulhi, should be better now.
  • Actually GCC should know the first 2 arguments are output-only; however there's no way to invoke an __asm__ while omitting the output operands. At least you need to declare dummy variables. (As far as I know)

@fredrik-johansson fredrik-johansson changed the title Fix unused variable warnings by using new umulhigh_pmm Fix unused variable warnings by using n_mulhi May 4, 2026
@fredrik-johansson fredrik-johansson merged commit 4300508 into flintlib:main May 4, 2026
12 checks passed
@fredrik-johansson
Copy link
Copy Markdown
Collaborator

Thanks!

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 this pull request may close these issues.

Compiler warnings about unused variables

4 participants