exercism / cpp

Exercism exercises in C++.
https://exercism.org/tracks/cpp
MIT License
252 stars 205 forks source link

Fix string literal comparison errors in bob_test.cpp #747

Closed mgrubb closed 8 months ago

mgrubb commented 8 months ago

When comparing against string literals with == operator compiler throws /Users/mgrubb/Exercism/cpp/bob/bob_test.cpp:15:25: error: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Werror,-Wstring-compare] REQUIRE("Whatever." == bob::hey("Tom-ay-to, tom-aaaah-to."));

This prevents the tests from passing. This change creates std::string constants to compare against.

github-actions[bot] commented 8 months ago

Hello. Thanks for opening a PR on Exercism 🙂

We ask that all changes to Exercism are discussed on our Community Forum before being opened on GitHub. To enforce this, we automatically close all PRs that are submitted. That doesn't mean your PR is rejected but that we want the initial discussion about it to happen on our forum where a wide range of key contributors across the Exercism ecosystem can weigh in.

You can use this link;%60%0D%0A%0D%0AThis%20prevents%20the%20tests%20from%20passing.%0D%0AThis%20change%20creates%20std::string%20constants%20to%20compare%20against.&category=cpp ) to copy this into a new topic on the forum. If we decide the PR is appropriate, we'll reopen it and continue with it, so please don't delete your local branch.

If you're interested in learning more about this auto-responder, please read this blog post.


Note: If this PR has been pre-approved, please link back to this PR on the forum thread and a maintainer or staff member will reopen it.

siebenschlaefer commented 8 months ago

Please discuss contributions like this in the forum first.

May I ask: What is the return type of hey in your function? It's probably not std::string nor std::string_view.