Bug 258394

Summary: archivers/upx: fix build with clang 13
Product: Ports & Packages Reporter: Dimitry Andric <dim>
Component: Individual Port(s)Assignee: Max Khon <fjoe>
Status: Closed FIXED    
Severity: Affects Some People Flags: bugzilla: maintainer-feedback? (fjoe)
Priority: ---    
Version: Latest   
Hardware: Any   
OS: Any   
Bug Depends on:    
Bug Blocks: 258209    
Attachments:
Description Flags
Fix unused-but-set variable in upx none

Description Dimitry Andric freebsd_committer freebsd_triage 2021-09-09 19:18:08 UTC
During an exp-run for llvm 13 (see bug 258209), it turned out that archivers/upx fails to build with clang 13 [1]:

p_wcle.cpp:739:27: error: variable 'n' set but not used [-Werror,-Wunused-but-set-variable]
    unsigned count,object,n,r;
                          ^
1 error generated.

This is because clang 13 now has a -Wunused-but-set-variable warning similar to gcc's, and it is enabled under -Wall.

The p_wcle.cpp file has two instances where the 'n' variable is used for debugging purposes, but the first instance is marked with UNUSED(n). The second is not, triggering this warning.

[1] http://gohan04.nyi.freebsd.org/data/mainamd64PR258209-default/2021-09-05_20h27m09s/logs/errors/upx-3.95.log
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2021-09-09 19:18:47 UTC
Created attachment 227794 [details]
Fix unused-but-set variable in upx
Comment 2 commit-hook freebsd_committer freebsd_triage 2021-10-02 10:52:39 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=89909595ad9b51a93554a9ee9db62c066c46a8bd

commit 89909595ad9b51a93554a9ee9db62c066c46a8bd
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2021-09-27 18:46:16 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2021-10-02 10:48:13 +0000

    archivers/upx: fix build with clang 13

    During an exp-run for llvm 13 (see bug 258209), it turned out that
    archivers/upx fails to build with clang 13:

    p_wcle.cpp:739:27: error: variable 'n' set but not used [-Werror,-Wunused-but-set-variable]
        unsigned count,object,n,r;
                              ^
    1 error generated.

    This is because clang 13 now has a -Wunused-but-set-variable warning
    similar to gcc's, and it is enabled under -Wall.

    The p_wcle.cpp file has two instances where the 'n' variable is used for
    debugging purposes, but the first instance is marked with UNUSED(n). The
    second is not, triggering this warning. Fix it by also marking the
    second instance with UNUSED(n).

    PR:             258394
    Approved by:    maintainer timeout (3 weeks)

 archivers/upx/files/patch-src_p__wcle.cpp (new) | 10 ++++++++++
 1 file changed, 10 insertions(+)