Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build error on 32-bit architecture due to missing static_casts #6377

Open
VVD opened this issue Apr 3, 2024 · 8 comments
Open

Build error on 32-bit architecture due to missing static_casts #6377

VVD opened this issue Apr 3, 2024 · 8 comments
Labels
build Everything related to compiling/building the code

Comments

@VVD
Copy link

VVD commented Apr 3, 2024

Description

Build error on i386 (ia32):

/wrkdirs/usr/ports/audio/mumble-server/work/mumble-1.5.613/src/MumbleProtocol.cpp:784:57: error: implicit conversion loses integer precision: 'std::uint64_t' (aka 'unsigned long long') to 'size_type' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
  784 |                 m_audioData.payload = gsl::span< byte >(payloadBegin, payloadSize);
      |                                       ~~~                             ^~~~~~~~~~~
/wrkdirs/usr/ports/audio/mumble-server/work/mumble-1.5.613/src/murmur/Server.cpp:1044:21: error: implicit conversion changes signedness: 'int' to 'std::vector<char>::size_type' (aka 'unsigned int') [-Werror,-Wsign-conversion]
                bufVec.resize(len + 4);
                       ~~~~~~ ~~~~^~~
1 error generated.
/wrkdirs/usr/ports/audio/mumble/work/mumble-1.5.613/src/mumble/Audio.cpp:46:25: error: implicit conversion loses integer precision: 'qint64' (aka 'long long') to 'long' [-Werror,-Wshorten-64-to-32]
   46 |                 long time = qetTicker.elapsed();
      |                      ~~~~   ~~~~~~~~~~^~~~~~~~~
1 error generated.
/wrkdirs/usr/ports/audio/mumble/work/mumble-1.5.613/src/mumble/AudioOutput.cpp:620:16: error: implicit conversion changes signedness: 'unsigned int' to 'std::ptrdiff_t' (aka 'int') [-Werror,-Wsign-conversion]
  620 |                                                         recbuff[i] += (pfBuffer[2 * i] / 2.0f + pfBuffer[2 * i + 1] / 2.0f) * volumeAdjustment;
      |                                                         ~~~~~~~ ^
/wrkdirs/usr/ports/audio/mumble/work/mumble-1.5.613/src/mumble/AudioOutput.cpp:624:16: error: implicit conversion changes signedness: 'unsigned int' to 'std::ptrdiff_t' (aka 'int') [-Werror,-Wsign-conversion]
  624 |                                                         recbuff[i] += pfBuffer[i] * volumeAdjustment;
      |                                                         ~~~~~~~ ^
2 errors generated.

FreeBSD 13.2, 13.3, 14.0, 15-CURRENT (main branch).

Steps to reproduce

  1. Build mumble

Mumble version

1.5.613

Mumble component

Both

OS

FreeBSD

Reproducible?

Yes

Additional information

No response

Relevant log output

No response

Screenshots

No response

@VVD VVD added bug A bug (error) in the software triage This issue is waiting to be triaged by one of the project members labels Apr 3, 2024
@VVD
Copy link
Author

VVD commented Apr 3, 2024

1st error fixed with patch:

--- src/MumbleProtocol.cpp.orig 2024-03-03 17:26:27 UTC
+++ src/MumbleProtocol.cpp
@@ -781,7 +781,7 @@ namespace Protocol {
                }


-               m_audioData.payload = gsl::span< byte >(payloadBegin, payloadSize);
+               m_audioData.payload = gsl::span< byte >(payloadBegin, static_cast< size_t >(payloadSize));

                if (stream.left() == 3 * sizeof(float)) {
                        // If there are further bytes after the audio payload, this means that there is positional data attached to

@VVD
Copy link
Author

VVD commented Apr 4, 2024

2nd error fixed with patch:

--- src/murmur/Server.cpp.orig  2024-03-03 17:26:27 UTC
+++ src/murmur/Server.cpp
@@ -1041,7 +1041,7 @@ void Server::sendMessage(ServerUser &u, const unsigned
                        ((reinterpret_cast< quint64 >(ebuffer.data()) + 8) & static_cast< quint64 >(~7)) + 4);
 #else
                std::vector< char > bufVec;
-               bufVec.resize(len + 4);
+               bufVec.resize(static_cast< std::size_t >(len + 4));
                char *buffer    = bufVec.data();
 #endif
                {

@VVD
Copy link
Author

VVD commented Apr 4, 2024

3rd:

--- src/mumble/Audio.cpp.orig   2024-03-03 17:26:27 UTC
+++ src/mumble/Audio.cpp
@@ -43,7 +43,7 @@ void LoopUser::addFrame(const Mumble::Protocol::AudioD
                QMutexLocker l(&qmLock);
                bool restart = (qetLastFetch.elapsed() > 100);

-               long time = qetTicker.elapsed();
+               long long time = qetTicker.elapsed();

                float r;
                if (restart)

4th:

--- src/mumble/AudioOutput.cpp.orig     2024-03-03 17:26:27 UTC
+++ src/mumble/AudioOutput.cpp
@@ -617,11 +617,11 @@ bool AudioOutput::mix(void *outbuff, unsigned int fram
                                                // Mix down stereo to mono. TODO: stereo record support
                                                // frame: for a stereo stream, the [LR] pair inside ...[LR]LRLRLR.... is a frame
                                                for (unsigned int i = 0; i < frameCount; ++i) {
-                                                       recbuff[i] += (pfBuffer[2 * i] / 2.0f + pfBuffer[2 * i + 1] / 2.0f) * volumeAdjustment;
+                                                       recbuff[static_cast< int >(i)] += (pfBuffer[2 * i] / 2.0f + pfBuffer[2 * i + 1] / 2.0f) * volumeAdjustment;
                                                }
                                        } else {
                                                for (unsigned int i = 0; i < frameCount; ++i) {
-                                                       recbuff[i] += pfBuffer[i] * volumeAdjustment;
+                                                       recbuff[static_cast< int >(i)] += pfBuffer[i] * volumeAdjustment;
                                                }
                                        }
 

or

--- src/mumble/AudioOutput.cpp.orig     2024-03-03 17:26:27 UTC
+++ src/mumble/AudioOutput.cpp
@@ -616,11 +616,11 @@ bool AudioOutput::mix(void *outbuff, unsigned int fram
                                        if (speech->bStereo) {
                                                // Mix down stereo to mono. TODO: stereo record support
                                                // frame: for a stereo stream, the [LR] pair inside ...[LR]LRLRLR.... is a frame
-                                               for (unsigned int i = 0; i < frameCount; ++i) {
+                                               for (int i = 0; i < frameCount; ++i) {
                                                        recbuff[i] += (pfBuffer[2 * i] / 2.0f + pfBuffer[2 * i + 1] / 2.0f) * volumeAdjustment;
                                                }
                                        } else {
-                                               for (unsigned int i = 0; i < frameCount; ++i) {
+                                               for (int i = 0; i < frameCount; ++i) {
                                                        recbuff[i] += pfBuffer[i] * volumeAdjustment;
                                                }
                                        }

@Krzmbrzl
Copy link
Member

Krzmbrzl commented Apr 4, 2024

Please submit a PR with your patches. The first patch should cast to std::size_t though, I think.

For a quick workaround you can also run cmake with -Dwarnings-as-errors=OFF.

@Krzmbrzl Krzmbrzl added build Everything related to compiling/building the code and removed bug A bug (error) in the software triage This issue is waiting to be triaged by one of the project members labels Apr 4, 2024
@Krzmbrzl Krzmbrzl changed the title Build error on i386 (ia32): src/MumbleProtocol.cpp:784:57: error: implicit conversion loses integer precision: 'std::uint64_t' (aka 'unsigned long long') to 'size_type' (aka 'unsigned int') Build error on 32-bit architecture due to missing static_casts Apr 4, 2024
@VVD
Copy link
Author

VVD commented Apr 5, 2024

Maybe you know how to create pool request from file with patch without fork the repo?

freebsd-git pushed a commit to freebsd/freebsd-ports that referenced this issue Apr 5, 2024
Upstream issue: mumble-voip/mumble#6377

Reported by:	pkg-fallout
Approved by:	arrowd (mentor, implicit)
@Krzmbrzl
Copy link
Member

Krzmbrzl commented Apr 6, 2024

Forking the repo is the correct (and only) way.

freebsd-git pushed a commit to freebsd/freebsd-ports that referenced this issue Apr 10, 2024
/wrkdirs/usr/ports/audio/mumble-server/work/mumble-1.5.613/src/murmur/Server.cpp:1044:21:
error: implicit conversion changes signedness: 'int' to 'std::vector<char>::size_type'
(aka 'unsigned int') [-Werror,-Wsign-conversion]
                bufVec.resize(len + 4);
                       ~~~~~~ ~~~~^~~
1 error generated.

Upstream issue: mumble-voip/mumble#6377

Reported by:	pkg-fallout
Approved by:	arrowd (mentor, implicit)
MFH:		2024Q2
freebsd-git pushed a commit to freebsd/freebsd-ports that referenced this issue Apr 10, 2024
/wrkdirs/usr/ports/audio/mumble-server/work/mumble-1.5.613/src/murmur/Server.cpp:1044:21:
error: implicit conversion changes signedness: 'int' to 'std::vector<char>::size_type'
(aka 'unsigned int') [-Werror,-Wsign-conversion]
                bufVec.resize(len + 4);
                       ~~~~~~ ~~~~^~~
1 error generated.

Upstream issue: mumble-voip/mumble#6377

Reported by:	pkg-fallout
Approved by:	arrowd (mentor, implicit)
MFH:		2024Q2

(cherry picked from commit f0a4c1f)
@VVD
Copy link
Author

VVD commented Apr 29, 2024

I don't want create personal fork for "oneliners".

@Krzmbrzl
Copy link
Member

It's literally free and it's the only way to create PRs for people without write access to the main repo. You can even do everything from the Browser. If you click on the edit button in a file, the fork will be created automatically in the process of changing the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Everything related to compiling/building the code
Projects
None yet
Development

No branches or pull requests

2 participants