public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* g++ doesn't diagnose implicit int error
@ 2019-06-10  4:38 Keith Thompson
  2019-06-11  7:48 ` Keith Thompson
  0 siblings, 1 reply; 4+ messages in thread
From: Keith Thompson @ 2019-06-10  4:38 UTC (permalink / raw)
  To: cygwin; +Cc: Keith Thompson

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-06-11 18:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-10  4:38 g++ doesn't diagnose implicit int error Keith Thompson
2019-06-11  7:48 ` Keith Thompson
2019-06-11 17:22   ` Achim Gratz
2019-06-11 18:35     ` Brian Inglis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).