RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2141218 - qemu-kvm build fails with clang 15.0.1 due to false unused variable error
Summary: qemu-kvm build fails with clang 15.0.1 due to false unused variable error
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: qemu-kvm
Version: 9.2
Hardware: Unspecified
OS: Unspecified
unspecified
urgent
Target Milestone: rc
: ---
Assignee: Miroslav Rezanina
QA Contact: jingzhao
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-11-09 07:24 UTC by Miroslav Rezanina
Modified: 2023-05-09 07:47 UTC (History)
6 users (show)

Fixed In Version: qemu-kvm-7.1.0-5.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-05-09 07:20:51 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Brew build log for failed build (2.03 MB, text/plain)
2022-11-09 07:24 UTC, Miroslav Rezanina
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-138769 0 None None None 2022-11-09 09:18:17 UTC
Red Hat Product Errata RHSA-2023:2162 0 None None None 2023-05-09 07:21:21 UTC

Description Miroslav Rezanina 2022-11-09 07:24:13 UTC
Created attachment 1923290 [details]
Brew build log for failed build

When running qemu-kvm build for RHEL 9.2 using clang 15.0.1, build fails with following error:

../hw/usb/host-libusb.c:1840:9: error: variable 'unconnected' set but not used [-Werror,-Wunused-but-set-variable]
    int unconnected = 0;
        ^
1 error generated.


Checking the source shows that variable is used and this error is false pass. 
Building exactly same code with clang 14.0.6 finished successfully.

Comment 1 Miroslav Rezanina 2022-11-09 08:33:47 UTC
Hit different error on another build:

../qemu-img.c:4925:13: error: variable 'block_count' set but not used [-Werror,-Wunused-but-set-variable]
    int64_t block_count = 0, out_pos, in_pos;
            ^
1 error generated.

Comment 2 Miroslav Rezanina 2022-11-09 08:35:32 UTC
Closer inspection shows that in both cases, variable is used only with ++ operator. Is there any change in logic for unused variables in 15.0.1 that cause this kind of usage is now reported as unused variable?

Comment 3 Tom Stellard 2022-11-09 16:34:06 UTC
(In reply to Miroslav Rezanina from comment #2)
> Closer inspection shows that in both cases, variable is used only with ++
> operator. Is there any change in logic for unused variables in 15.0.1 that
> cause this kind of usage is now reported as unused variable?

Yes, there was an improvement to that diagnostic that caused it to start detecting when the only use was with ++ operator: https://releases.llvm.org/15.0.0/tools/clang/docs/ReleaseNotes.html#improvements-to-clang-s-diagnostics

Do you have a link to the full source file?

Comment 4 Miroslav Rezanina 2022-11-09 16:52:15 UTC
(In reply to Tom Stellard from comment #3)
> (In reply to Miroslav Rezanina from comment #2)
> > Closer inspection shows that in both cases, variable is used only with ++
> > operator. Is there any change in logic for unused variables in 15.0.1 that
> > cause this kind of usage is now reported as unused variable?
> 
> Yes, there was an improvement to that diagnostic that caused it to start
> detecting when the only use was with ++ operator:
> https://releases.llvm.org/15.0.0/tools/clang/docs/ReleaseNotes.
> html#improvements-to-clang-s-diagnostics
> 
> Do you have a link to the full source file?

I miss on original warning that code reading the variable is disabled.

I detected four new places causing this warning and already sent fixes upstream:

https://lists.nongnu.org/archive/html/qemu-devel/2022-11/msg01639.html

You can see the files here:

https://git.qemu.org/?p=qemu.git;a=blob;f=qemu-img.c;h=a3b64c88af0f4fce8da9521206ef6a2302bb80e8;hb=HEAD
https://git.qemu.org/?p=qemu.git;a=blob;f=hw/usb/host-libusb.c;h=28f8af8941ff6db20283fcd85d23da120abc6cee;hb=HEAD
https://git.qemu.org/?p=qemu.git;a=blob;f=hw/net/tulip.c;h=b9e42c322ab1fb92416adfc5fda94a93c77543cf;hb=HEAD
https://git.qemu.org/?p=qemu.git;a=blob;f=hw/net/rtl8139.c;h=6b65823b4bf8cab4e5d208f5abcbbbd4343041d3;hb=HEAD

Comment 5 Miroslav Rezanina 2022-11-10 03:41:52 UTC
As the issue is not on the side of compiler, reassign to qemu-kvm that has to fix this.

Comment 7 Yanan Fu 2022-11-15 12:42:13 UTC
QE bot(pre verify): Set 'Verified:Tested,SanityOnly' as gating/tier1 test pass.

Comment 15 errata-xmlrpc 2023-05-09 07:20:51 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: qemu-kvm security, bug fix, and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2023:2162


Note You need to log in before you can comment on or make changes to this bug.