Bug 263545 - sysutils/uefi-edk2-bhyve: Fails to build with GCC 11: error: argument 2 of type 'const uint8_t *' {aka 'const unsigned char *'} declared as a pointer [-Werror=vla-parameter]
Summary: sysutils/uefi-edk2-bhyve: Fails to build with GCC 11: error: argument 2 of t...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Dima Panov
URL: http://package18.nyi.freebsd.org/data...
Keywords:
Depends on:
Blocks: 258378
  Show dependency treegraph
 
Reported: 2022-04-24 22:39 UTC by Lorenzo Salvadore
Modified: 2022-05-06 19:43 UTC (History)
2 users (show)

See Also:
salvadore: maintainer-feedback? (bcran)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lorenzo Salvadore freebsd_committer freebsd_triage 2022-04-24 22:39:59 UTC
Updating GCC_DEFAULT from GCC 10 to GCC 11 is blocked by the fact that building this port with GCC 11 gives the following error (full log in URL):

/gcc  -c -I ./brotli/c/include -I .. -I ../Include/Common -I ../Include/ -I ../Include/IndustryStandard -I ../Common/ -I .. -I . -I ../Include/X64/ -MD -fshort-wchar -fno-strict-aliasing -fwrapv -fno-delete-null-pointer-checks -Wall -Werror -Wno-deprecated-declarations -Wno-stringop-truncation -Wno-restrict -Wno-unused-result -nostdlib -g -O2  brotli/c/dec/decode.c -o brotli/c/dec/decode.o
g++ -c -I Pccts/h -I .. -I ../Include/Common -I ../Include/ -I ../Include/IndustryStandard -I ../Common/ -I .. -I . -I ../Include/X64/ -Wno-unused-result -O2  EfiVfrParser.cpp -o EfiVfrParser.o
brotli/c/dec/decode.c:2033:41: error: argument 2 of type 'const uint8_t *' {aka 'const unsigned char *'} declared as a pointer [-Werror=vla-parameter]
 2033 |     size_t encoded_size, const uint8_t* encoded_buffer, size_t* decoded_size,
      |                          ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
In file included from brotli/c/dec/decode.c:7:
./brotli/c/include/brotli/decode.h:204:19: note: previously declared as a variable length array 'const uint8_t[*decoded_size]' {aka 'const unsigned char[*decoded_size]'}
  204 |     const uint8_t encoded_buffer[BROTLI_ARRAY_PARAM(encoded_size)],
      |     ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
brotli/c/dec/decode.c:2034:14: error: argument 4 of type 'uint8_t *' {aka 'unsigned char *'} declared as a pointer [-Werror=vla-parameter]
 2034 |     uint8_t* decoded_buffer) {
      |     ~~~~~~~~~^~~~~~~~~~~~~~
In file included from brotli/c/dec/decode.c:7:
./brotli/c/include/brotli/decode.h:206:13: note: previously declared as a variable length array 'uint8_t[encoded_size]' {aka 'unsigned char[encoded_size]'}
  206 |     uint8_t decoded_buffer[BROTLI_ARRAY_PARAM(*decoded_size)]);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
g++ -c -I Pccts/h -I .. -I ../Include/Common -I ../Include/ -I ../Include/IndustryStandard -I ../Common/ -I .. -I . -I ../Include/X64/ -Wno-unused-result -O2  VfrLexer.cpp -o VfrLexer.o
In file included from VfrLexer.cpp:22124:
Pccts/h/DLexer.h: In member function 'virtual ANTLRTokenType VfrLexer::nextTokenType()':
Pccts/h/DLexer.h:68:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   68 |         register int state, newstate;
      |                      ^~~~~
Pccts/h/DLexer.h:68:29: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   68 |         register int state, newstate;
      |                             ^~~~~~~~
Pccts/h/DLexer.h:70:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   70 |         register DLGChar *lastpos;
      |                           ^~~~~~~
g++ -c -DPCCTS_USE_NAMESPACE_STD -I Pccts/h -I .. -I ../Include/Common -I ../Include/ -I ../Include/IndustryStandard -I ../Common/ -I .. -I . -I ../Include/X64/  -O2  VfrSyntax.cpp -o VfrSyntax.o
cc1: all warnings being treated as errors
gmake[3]: *** [../Makefiles/footer.makefile:21: brotli/c/dec/decode.o] Error 1


Also, it should be checked if USE_GCC is still needed and that the default clang compiler can't be used instead.
Comment 1 commit-hook freebsd_committer freebsd_triage 2022-05-05 10:26:54 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=345fdf99b13a6ddecf78058ab92ea89fa12b0d21

commit 345fdf99b13a6ddecf78058ab92ea89fa12b0d21
Author:     Dima Panov <fluffy@FreeBSD.org>
AuthorDate: 2022-05-05 10:18:05 +0000
Commit:     Dima Panov <fluffy@FreeBSD.org>
CommitDate: 2022-05-05 10:25:47 +0000

    sysutils/uefi-edk2-bhyve: fix build with modern compilers

    Since GCC11/Clang13, build was failed with error:
    argument 2 of type 'const uint8_t *' {aka 'const unsigned char *'} declared as a pointer [-Werror=vla-parameter]

    Backport patch from brotli upstream

    While here, fix string pointer overflows in USB handler code [1]

    PR:     263545
    Approved by:    portmgr blanket (Tier 1 fix build)
    Obtained from:  Gentoo bug#801925 [1]

 sysutils/uefi-edk2-bhyve/Makefile                  |  1 +
 .../uefi-edk2-bhyve/files/patch-fix-warnings (new) | 29 ++++++++++++++++++++++
 .../files/patch-stringpop-overflows (new)          | 22 ++++++++++++++++
 3 files changed, 52 insertions(+)
Comment 2 Lorenzo Salvadore freebsd_committer freebsd_triage 2022-05-06 09:51:32 UTC
Thanks Dima for your commit. Is the issue fixed then? Can we close the bug?

Triage: if your commit has indeed resolved the issue and you close the bug, please also re-assign the bug to yourself.
https://wiki.freebsd.org/Bugzilla/TriageTraining#Closed.2FClosing_Issues
Comment 3 Dima Panov freebsd_committer freebsd_triage 2022-05-06 19:43:32 UTC
(In reply to Lorenzo Salvadore from comment #2)
At least, it fix build for me with recent releases so think it can be closed now.

Sure, if anyone will raise complais, PR can be reopened :)