User forums > General (but related to Code::Blocks)
tdm64-gcc compiler errors & warnings
yvesdm3000:
GCC 4.8 on your linux machine is older than your mingw GCC versions (5.1 and 5.3). Newer versions tend to be improved and have often more warnings and follow specs better.
Yves
kaa:
The problem is the opposite: the MinGW compilers are LESS compliant with C++ standards than the older GCC compiler.
Under every C++ standard going back to 98, the compiler should at least warn that "ISO C++ forbids declaration of [function] with no type". GCC 4.8.4 warns on declaration of main with no type but defaults to int and compiles. But it errors on declaration of any other function with no type and refuses to compile. And the "missing field initializers" warning should be given under -std=c++11 or later.
All 3 of these MinGW compilers compile the code with no errors, no warnings.
Here's an even simpler version of the program. It doesn't use std::array but should still produce the same error and warning messages. But the MinGW compilers build it with no errrors or warnings at all.
--- Code: ---#include <iostream>
struct array5 {
int nums[5];
int& operator[](int idx) {
return nums[idx];
}
int const& operator[](int idx) const{
return nums[idx];
}
};
getSum(array5 arr) // no return type ERROR
{
int sumIt(0);
int sz = 5;
for(int i = 0; i < sz; i++)
sumIt += arr[i];
return sumIt;
}
main() // no return type WARNING
{
array5 myInts{}; // missing field initializers WARNING
for(int i = 0; i < 5; i++) {
myInts[i] = i+90;
}
std::cout << getSum(myInts) << std::endl;
return (0);
}
--- End code ---
Edited to add this code.
oBFusCATed:
What happens if you add #error "this is an error" and #warning "this is a warning" in the source file?
stahta01:
The problem exists in MSys2 MinGW 64.
The option "-Wreturn-type" does NOT even get the warning to appear.
--- Code: ---x86_64-w64-mingw32-g++.exe (Rev1, Built by MSYS2 project) 5.3.0
--- End code ---
I would guess the problem is in MinGW64 code.
I finally got TDM Compiler installed output below:
--- Code: ----------------- Clean: Debug in warntest (compiler: GNU GCC Compiler MinGW64 TDM 5.1)---------------
Cleaned "warntest - Debug"
Running target pre-build steps
g++.exe --version
g++.exe (tdm64-1) 5.1.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-------------- Build: Debug in warntest (compiler: GNU GCC Compiler MinGW64 TDM 5.1)---------------
g++.exe -Wall -fexceptions -pedantic -Wextra -Wall -std=c++11 -g -Wreturn-type -fno-permissive -c C:\SourceCode\test\warntest\main.cpp -o obj\Debug\main.o
C:\SourceCode\test\warntest\main.cpp:15:2: warning: #warning is a GCC extension
#warning "this is a warning"
^
C:\SourceCode\test\warntest\main.cpp:15:2: warning: #warning "this is a warning" [-Wcpp]
g++.exe -o bin\Debug\warntest.exe obj\Debug\main.o
Output file is bin\Debug\warntest.exe with size 2.61 MB
Process terminated with status 0 (0 minute(s), 2 second(s))
0 error(s), 2 warning(s) (0 minute(s), 2 second(s))
--- End code ---
Tim S.
oBFusCATed:
-Wreturn-type is not warning about this issue, but if there is a missing return in a function that has void return type.
Anyway if there is a separate confirmation about this issue we can conclude that the only party that can explain what is happening is the people in the MinGW project. So please better direct further questions to them.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version