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

Fix some errors uncovered via compiler warnings #7954

Merged
merged 8 commits into from
Jan 8, 2025

Conversation

undingen
Copy link
Contributor

@undingen undingen commented Jan 7, 2025

Fix some of the compiler warnings I was seeing while compiling the project with gcc 14.2.
Some things uncovered real bugs.

```
OrcaSlicer/src/libslic3r/calib.cpp:456:17: warning: possibly dangling reference to a temporary [-Wdangling-reference]
  456 |     const auto &w         = bed_ext.size().x();
OrcaSlicer/src/libslic3r/calib.cpp:456:45: note: the temporary was destroyed at the end of the full expression ‘((Eigen::DenseCoeffsBase<Eigen::Matrix<double, 2, 1, 2>, 1>*)(& Slic3r::BoundingBoxBase<PointClass>::size() const [with PointClass = Eigen::Matrix<double, 2, 1, 2>]()))->Eigen::DenseCoeffsBase<Eigen::Matrix<double, 2, 1, 2>, 1>::x()’
  456 |     const auto &w         = bed_ext.size().x();
```
in this case I think it actually does not change the semantics it just means that both comparison have to be evaluated.
OrcaSlicer/src/slic3r/GUI/MediaPlayCtrl.cpp:392: warning: multi-character character constant [-Wmultichar]
  392 |     if (auto n = tunnel.find_first_of('/_'); n != std::string::npos)
OrcaSlicer/src/slic3r/GUI/MediaPlayCtrl.cpp: In member function ‘void Slic3r::GUI::MediaPlayCtrl::Stop(const wxString&)’:
OrcaSlicer/src/slic3r/GUI/MediaPlayCtrl.cpp:392: warning: overflow in conversion from ‘int’ to ‘char’ changes value from ‘12127’ to ‘95’ [-Woverflow]
@undingen undingen changed the title Fix some of the compiler warnings I was seeing while compiling the project with gcc 14.2 Fix some error uncovered via compiler warnings Jan 7, 2025
@undingen undingen changed the title Fix some error uncovered via compiler warnings Fix some errors uncovered via compiler warnings Jan 7, 2025
@henrivdr
Copy link
Contributor

henrivdr commented Jan 7, 2025

Nice!

@@ -389,7 +389,7 @@ void MediaPlayCtrl::Stop(wxString const &msg)
}

auto tunnel = m_url.empty() ? "" : into_u8(wxURI(m_url).GetPath()).substr(1);
if (auto n = tunnel.find_first_of('/_'); n != std::string::npos)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't even know c++ allows this!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I was also surprised this is allowed

Copy link
Collaborator

@Noisyfox Noisyfox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

@Noisyfox Noisyfox merged commit 2b95ef4 into SoftFever:main Jan 8, 2025
16 checks passed
shuwn pushed a commit to shuwn/OrcaSlicer that referenced this pull request Jan 11, 2025
* fix: tray_exist_bits != tray_exist_bits comparison

* fix: title == GetTitle() == title comparison

* fix: possibly dangling reference to a temporary
```
OrcaSlicer/src/libslic3r/calib.cpp:456:17: warning: possibly dangling reference to a temporary [-Wdangling-reference]
  456 |     const auto &w         = bed_ext.size().x();
OrcaSlicer/src/libslic3r/calib.cpp:456:45: note: the temporary was destroyed at the end of the full expression ‘((Eigen::DenseCoeffsBase<Eigen::Matrix<double, 2, 1, 2>, 1>*)(& Slic3r::BoundingBoxBase<PointClass>::size() const [with PointClass = Eigen::Matrix<double, 2, 1, 2>]()))->Eigen::DenseCoeffsBase<Eigen::Matrix<double, 2, 1, 2>, 1>::x()’
  456 |     const auto &w         = bed_ext.size().x();
```

* fix: mixup of | and ||
in this case I think it actually does not change the semantics it just means that both comparison have to be evaluated.

* fix: multi-character character constants need "

OrcaSlicer/src/slic3r/GUI/MediaPlayCtrl.cpp:392: warning: multi-character character constant [-Wmultichar]
  392 |     if (auto n = tunnel.find_first_of('/_'); n != std::string::npos)
OrcaSlicer/src/slic3r/GUI/MediaPlayCtrl.cpp: In member function ‘void Slic3r::GUI::MediaPlayCtrl::Stop(const wxString&)’:
OrcaSlicer/src/slic3r/GUI/MediaPlayCtrl.cpp:392: warning: overflow in conversion from ‘int’ to ‘char’ changes value from ‘12127’ to ‘95’ [-Woverflow]

* fix: missing paranthesis - skips null check

* NFC: Remove this check it can never be false

* NFC: fix warning: statement has no effect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants