1

I am trying to test a little C++17. I am trying to do:

[[nodiscard]] int get_value1()
{
    return 42;
}

inline void start()
{
    // Should generate warning
    get_value1();
}

However, it does not. I am using Visual studio 2017. Warning level set to Level4(\W4). I have set C++ Language Standard to ISO C++ Latest Draft Standard (/std:c++latest).

But it does not generate the warning that I want. Why is that? Also, a little side question: That tab to select the language standard only appears in Debug configuration and not Release. Why is that? Release complains on the nodiscard, Would that mean that Release is in C++14?

edit: naturally I meant warning in the second section. Corrected. :)

Alex Guteniev
  • 12,039
  • 2
  • 34
  • 79
Alex
  • 365
  • 4
  • 17
  • VS doesnt fully implement these attributes yet AFAIK – Hatted Rooster Jul 09 '17 at 13:10
  • As to your question about release, I would expect that making certain features work without optimization is easier than with optimization. – Preet Kukreti Jul 09 '17 at 13:12
  • Is there a Visual studio patch notes/ compilation list over the coming features that is implemented and/or to be implemented in upcoming patch because that would be very helpful. – Alex Jul 09 '17 at 13:13
  • Which VS 2017 do you use? Actually [[nodiscard]] is supported only since VS 2017.3. – Nikolai Shalakin Jul 09 '17 at 13:13
  • 1
    I also think the wording of the requirement is a little off: _"..the compiler is __encouraged__ to issue a warning."_ source: http://en.cppreference.com/w/cpp/language/attributes Same wording in the current draft: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4659.pdf – Richard Critten Jul 09 '17 at 13:14
  • I updated my Visual studio through the client itself where 2017.3 hadn't been released yet. As far as I can tell it's still in a preview state so Nikolai Shalakin has answered my question. Will close this question as soon as it lets me. – Alex Jul 09 '17 at 13:20

1 Answers1

1

Actually [[nodiscard]] is supported only since VS 2017.3 and it should give you a warning, not an error. And as I understand specification assumes that compiler may warn you. And may not.

Nikolai Shalakin
  • 1,349
  • 2
  • 13
  • 25