rstudio / httpuv

HTTP and WebSocket server package for R
Other
224 stars 84 forks source link

Warning with clang 16 #354

Closed wch closed 1 year ago

wch commented 1 year ago

I received an email from BDR about a warning from clang 16.

clang 16 is being prepared for release in early March, so it is time to start reporting its issues. See https://www.stats.ox.ac.uk/pub/bdr/clang16/ including its README.txt

From https://www.stats.ox.ac.uk/pub/bdr/clang16/httpuv.out:

Found the following significant warnings:
  httprequest.cpp:808:7: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
See ‘/data/gannet/ripley/R/packages/tests-clang-trunk/httpuv.Rcheck/00install.out’ for details.
wch commented 1 year ago

The problem is here:

https://github.com/rstudio/httpuv/blob/650ba73f7b54cc494114d4b5e3ad0214523e6aad/src/httprequest.cpp#L808

It calls .empty() on a vector, but that's the wrong method: it reports whether or not the vector is empty, but I believe the goal is to clear the vector, in which case the correct method is .clear().

wch commented 1 year ago

Looking at the history, the .empty() was originally introduced in bdaee938bd9bb1d7f72e50e49de7821d279aa95a., and then was moved to a new location in 5178f6ac2f9a43845388be27ac2b36d99034a765.