This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

g++ doesn't diagnose implicit int error


See https://stackoverflow.com/q/56519330/827263 posted by user Fureeish

g++ on Cygwin does not diagnose an implicit int error.
The same version of g++ on Ubuntu correctly diagnoses the error.

(I had initially thought that g++ was defaulting to "-fpermissive",
but that would change the fatal error to a warning.  Instead, no
diagnostic message is being produced at all.)

This script "implicit_int_bug.sh" demonstrates the problem:
=== CUT HERE ===
#!/bin/sh

verbosely() {
    echo "% $*"
    "$@" || echo ">>> exit $?"
}

verbosely uname -a
verbosely g++ --version

echo 'func() { }' > implicit_int.cpp
verbosely cat implicit_int.cpp

echo ">>> EXPECTED: warning: ISO C++ forbids declaration of ‘ptr’ with
no type [-fpermissive]"
verbosely g++ -c -fpermissive implicit_int.cpp

echo ">>> EXPECTED: error: ISO C++ forbids declaration of ‘notype’
with no type [-fpermissive]"
verbosely g++ -c implicit_int.cpp

echo ">>> EXPECTED: error: ISO C++ forbids declaration of ‘notype’
with no type [-fpermissive]"
verbosely g++ -c -std=c++11 -pedantic implicit_int.cpp
=== AND HERE ===

The output under 64-bit Cygwin on Windows 10.
This demonstrates the problem.
=== CUT HERE ===
% uname -a
CYGWIN_NT-10.0 eddie 3.0.7(0.338/5/3) 2019-04-30 18:08 x86_64 Cygwin
% g++ --version
g++ (GCC) 7.4.0
Copyright (C) 2017 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.

% cat implicit_int.cpp
func() { }
>>> EXPECTED: warning: ISO C++ forbids declaration of ‘ptr’ with no type [-fpermissive]
% g++ -c -fpermissive implicit_int.cpp
>>> EXPECTED: error: ISO C++ forbids declaration of ‘notype’ with no type [-fpermissive]
% g++ -c implicit_int.cpp
>>> EXPECTED: error: ISO C++ forbids declaration of ‘notype’ with no type [-fpermissive]
% g++ -c -std=c++11 -pedantic implicit_int.cpp
=== AND HERE ===

Output of the same script (note the same version of g++) on Ubuntu 18.04.
This does NOT demonstrate the problem.
=== CUT HERE ===
% uname -a
Linux bomb20 4.15.0-50-generic #54-Ubuntu SMP Mon May 6 18:46:08 UTC
2019 x86_64 x86_64 x86_64 GNU/Linux
% g++ --version
g++ (Ubuntu 7.4.0-1ubuntu1~18.04) 7.4.0
Copyright (C) 2017 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.

% cat implicit_int.cpp
func() { }
>>> EXPECTED: warning: ISO C++ forbids declaration of ‘ptr’ with no type [-fpermissive]
% g++ -c -fpermissive implicit_int.cpp
implicit_int.cpp:1:6: warning: ISO C++ forbids declaration of ‘func’
with no type [-fpermissive]
 func() { }
      ^
>>> EXPECTED: error: ISO C++ forbids declaration of ‘notype’ with no type [-fpermissive]
% g++ -c implicit_int.cpp
implicit_int.cpp:1:6: error: ISO C++ forbids declaration of ‘func’
with no type [-fpermissive]
 func() { }
      ^
>>> exit 1
>>> EXPECTED: error: ISO C++ forbids declaration of ‘notype’ with no type [-fpermissive]
% g++ -c -std=c++11 -pedantic implicit_int.cpp
implicit_int.cpp:1:6: error: ISO C++ forbids declaration of ‘func’
with no type [-fpermissive]
 func() { }
      ^
>>> exit 1
=== AND HERE ===

I see the same problem on Cygwin with i686-w64-mingw32-g++,
x86_64-pc-cygwin-g++, and x86_64-w64-mingw32-g++ (all version 7.4.0).

The Stack Overflow post refers to a similar problem with MinGW.

I've seen the same problem on MSYS2, g++ 7.4.0.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]