LINUX.ORG.RU

История изменений

Исправление XMs, (текущая версия) :

Вот так работает:

xms@XMs-desktop ~/projects/tests/scan-build-c++11/build $ cat ../main.cpp 
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>



using namespace std;

int main()
  {
        vector<string> v1 = {"aaa", "bbb", "ccc"};
        vector<string> v2 = move(v1);

        cout << "v1:" << endl;
        for (const string &s: v1)
                cout << s << endl;

        cout << endl << "v2:" << endl;
        for (const string &s:v2)
                cout << s << endl;

        cout << endl << "lambd-ass:" << endl;
        vector<int> someList;
        int total = 0;
        for_each(someList.begin(), someList.end(), [&total](int x) { total += x; });
        cout << "Total: " << total << endl;

        return EXIT_SUCCESS;
  }
xms@XMs-desktop ~/projects/tests/scan-build-c++11/build $ cat ../CMakeLists.txt 
cmake_minimum_required(VERSION 3.0)
add_definitions("-std=c++11")
add_executable(scanbuildtest main.cpp)
xms@XMs-desktop ~/projects/tests/scan-build-c++11/build $ scan-build cmake ../
scan-build: Using '/usr/bin/x86_64-pc-linux-gnu-clang-3.7' for static analysis
-- The C compiler identification is GNU 4.9.3
-- The CXX compiler identification is GNU 4.9.3
-- Check for working C compiler: /usr/bin/ccc-analyzer
-- Check for working C compiler: /usr/bin/ccc-analyzer — works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++-analyzer
-- Check for working CXX compiler: /usr/bin/c++-analyzer — works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/xms/projects/tests/scan-build-c++11/build
scan-build: Removing directory '/tmp/scan-build-2016-10-05-003649-21242-1' because it contains no reports.
scan-build: No bugs found.
xms@XMs-desktop ~/projects/tests/scan-build-c++11/build $ scan-build make
scan-build: Using '/usr/bin/x86_64-pc-linux-gnu-clang-3.7' for static analysis
Scanning dependencies of target scanbuildtest
[ 50%] Building CXX object CMakeFiles/scanbuildtest.dir/main.cpp.o
[100%] Linking CXX executable scanbuildtest
[100%] Built target scanbuildtest
scan-build: Removing directory '/tmp/scan-build-2016-10-05-003700-21459-1' because it contains no reports.
scan-build: No bugs found.
xms@XMs-desktop ~/projects/tests/scan-build-c++11/build $

Исходная версия XMs, :

Вот так работает:

xms@XMs-desktop ~/projects/tests/scan-build-c++11/build $ cat ../main.cpp 
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>



using namespace std;

int main()
  {
        vector<string> v1 = {"aaa", "bbb", "ccc"};
        vector<string> v2 = move(v1);

        cout << "v1:" << endl;
        for (const string &s: v1)
                cout << s << endl;

        cout << endl << "v2:" << endl;
        for (const string &s:v2)
                cout << s << endl;

        cout << endl << "lambd-ass:";
        vector<int> someList;
        int total = 0;
        for_each(someList.begin(), someList.end(), [&total](int x) { total += x; });
        cout << total << endl;

        return EXIT_SUCCESS;
  }
xms@XMs-desktop ~/projects/tests/scan-build-c++11/build $ cat ../CMakeLists.txt 
cmake_minimum_required(VERSION 3.0)
add_definitions("-std=c++11")
add_executable(scanbuildtest main.cpp)
xms@XMs-desktop ~/projects/tests/scan-build-c++11/build $ scan-build cmake ../
scan-build: Using '/usr/bin/x86_64-pc-linux-gnu-clang-3.7' for static analysis
-- The C compiler identification is GNU 4.9.3
-- The CXX compiler identification is GNU 4.9.3
-- Check for working C compiler: /usr/bin/ccc-analyzer
-- Check for working C compiler: /usr/bin/ccc-analyzer — works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++-analyzer
-- Check for working CXX compiler: /usr/bin/c++-analyzer — works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/xms/projects/tests/scan-build-c++11/build
scan-build: Removing directory '/tmp/scan-build-2016-10-05-003649-21242-1' because it contains no reports.
scan-build: No bugs found.
xms@XMs-desktop ~/projects/tests/scan-build-c++11/build $ scan-build make
scan-build: Using '/usr/bin/x86_64-pc-linux-gnu-clang-3.7' for static analysis
Scanning dependencies of target scanbuildtest
[ 50%] Building CXX object CMakeFiles/scanbuildtest.dir/main.cpp.o
[100%] Linking CXX executable scanbuildtest
[100%] Built target scanbuildtest
scan-build: Removing directory '/tmp/scan-build-2016-10-05-003700-21459-1' because it contains no reports.
scan-build: No bugs found.
xms@XMs-desktop ~/projects/tests/scan-build-c++11/build $