User forums > General (but related to Code::Blocks)
tdm64-gcc compiler errors & warnings
kaa:
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?
--- Code: ---#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);
}
--- End code ---
These are the compiler messages I expect (and get in Linux):
--- Code: ---$ 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{};
^
^
--- End code ---
stahta01:
Post the full CB rebuild log!!
http://wiki.codeblocks.org/index.php/FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F
Till I see one; I will ignore this thread as a waste of time.
Tim S.
kaa:
Sorry, I don't think this will help, but ...
--- Code: ----------------- Build: Debug in cordova (compiler: GNU GCC Compiler)---------------
g++.exe -fexceptions -pedantic -Wextra -Wall -std=c++11 -c E:\progs\c++\cordova\main.cpp -o obj\Debug\main.o
g++.exe -o bin\Debug\cordova.exe obj\Debug\main.o
Output file is bin\Debug\cordova.exe with size 2.58 MB
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
--- End code ---
As I said, same command as in Linux.
It's not a Code::Blocks issue. It compiles without errors or warnings on the command line also.
oBFusCATed:
Are you sure you're building the correct file?
kaa:
Absolutely sure.
I've done some more testing and it turns out that not only tdm64-gcc-5.1.0-2 but also mingw-w64-x86_64-5.3.0-posix-sjlj-rt_v4-rev0
and mingw-w64-i686-5.3.0-posix-dwarf-rt_v4-rev0 all omit the no return type warning/error and the missing field initializers warning.
The same code will not compile in Visual Studio or in Linux with gcc 4.8.4.
Any ideas why the Windows gcc ports should differ on this?
Navigation
[0] Message Index
[#] Next page
Go to full version