source: trunk/bug/std_vector.sh @ 2932

Last change on this file since 2932 was 2932, checked in by bradbell, 7 years ago

std_vector.sh: deomonstrate unexpected behavior by standard vector.

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 852 bytes
Line 
1#! /bin/bash -e
2# -----------------------------------------------------------------------------
3# Using g++ 4.8.1 results in the following error message:
4#
5# std_vector.cpp:8:7: error: no match for ‘operator|=’ (operand types are
6# ‘std::vector<bool>::reference {aka std::_Bit_reference}’ and ‘bool’)
7#  y[1] |= true;
8#       ^
9# -----------------------------------------------------------------------------
10if [ ! -e build ]
11then
12        mkdir build
13fi
14cd build
15echo "$0"
16name=`echo $0 | sed -e 's|.*/||' -e 's|\..*||'`
17cat << EOF > $name.cpp
18# include <vector>
19int main(void)
20{       int N = 1;
21        std::vector<bool> y(N);
22        for(int i = 0; i < N; i++ )
23                y[i] = false;
24        y[0]  = y[0] | true;
25        y[1] |= true;
26        return 0;
27}
28EOF
29echo "g++ -g $name.cpp -o $name"
30g++ -g $name.cpp -o $name
31#
32echo "./$name"
33./$name
34#
35echo "rm $name $name.cpp"
36rm $name $name.cpp
Note: See TracBrowser for help on using the repository browser.