Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSVC gives warning C26478 "using std::move on constant variables"

Tags:

c++

I have the following code that returns a warning C26478 with MSVC 1937 (with /W4). However both clang and gcc (with -Wpedantic -Wextra -Wall) are fine with this code.

std::tuple<int, int> i_make_tuples(){
    return std::make_tuple(42,23);
}

int main() {
    auto const [x,y] = i_make_tuples(); // C26478 (Don't use std::move on constant variables) reported here
}

Am I wrong or is this warning unjustified in this case?

like image 297
user2393256 Avatar asked Oct 11 '25 11:10

user2393256


1 Answers

This is indeed a false positive, which has been acknowledged as a bug by the MSVC developers.

like image 177
You Avatar answered Oct 14 '25 02:10

You