Hi all. This is actually about the tdm mingw compiler rather than code::blocks specifically but since you guys recommend that compiler I hope the question is appropriate here.
So, when I try to compile the following trivial code I expect that it should produce 2 warnings and an error and should fail to compile. In fact this is what happens when I compile it in Linux with gcc 4.8.4.
So why does it compile with no error and no warnings at all, using the same command in windows with tdm64 ver 5.1.0-2? Is this a bug in TDM64 or mingw or do I have something configured wrong?
#include <iostream>
#include <array>
using namespace std;
getSum(array<int,5>& arr)
{
int sumIt(0);
for(auto& elem: arr)
sumIt += elem;
return sumIt;
}
main()
{
array<int,5> myInts{};
for(int i = 0; i < 5; i++) {
myInts[i] = i+1;
}
cout << getSum(myInts) << endl;
return (0);
}
These are the compiler messages I expect (and get in Linux):
$ g++ -g -Wall -Wextra -pedantic -std=c++11 -c main.cpp
main.cpp:6:25: error: ISO C++ forbids declaration of ‘getSum’ with no type [-fpermissive]
getSum(array<int,5>& arr)
^
main.cpp:16:6: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wpedantic]
main()
^
main.cpp: In function ‘int main()’:
main.cpp:18:25: warning: missing initializer for member ‘std::array<int, 5ul>::_M_elems’ [-Wmissing-field-initializers]
array<int,5> myInts{};
^
^