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

* Re: g++ doesn't diagnose implicit int error
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Keith Thompson @ 2019-06-11  7:48 UTC (permalink / raw)
  To: cygwin; +Cc: Keith Thompson

I believe this answer by user "M.M" on Stack Overflow explains the issue:
https://stackoverflow.com/a/56537459/827263

On Windows targets (including Cygwin and MinGW), the "-fms-extensions"
option is enabled by default.  This option enables certain Microsoft
extensions -- and apparently inhibits any diagnostics for implicit int.

It is unfortunate, and arguably a bug, that this means that
"g++ -std=c++11 -pedantic" fails to diagnose implicit int errors.
I'm not sure whether this is a bug in gcc or in the way Windows
versions of gcc are built.

Meanwhile, this can be worked around by using "g++ -fno-ms-extensions ...".
This which might cause problems when compiling some Windows headers,
but M.M reports being able to compile some large Windows projects
this way without running into problems.

There's also a "-fms-extensions" option for C, but gcc warns about
implicit int declarations in C with or without that option.

--
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

* Re: g++ doesn't diagnose implicit int error
  2019-06-11  7:48 ` Keith Thompson
@ 2019-06-11 17:22   ` Achim Gratz
  2019-06-11 18:35     ` Brian Inglis
  0 siblings, 1 reply; 4+ messages in thread
From: Achim Gratz @ 2019-06-11 17:22 UTC (permalink / raw)
  To: cygwin

Keith Thompson writes:
> On Windows targets (including Cygwin and MinGW), the "-fms-extensions"
> option is enabled by default.  This option enables certain Microsoft
> extensions -- and apparently inhibits any diagnostics for implicit int.
>
> It is unfortunate, and arguably a bug, that this means that
> "g++ -std=c++11 -pedantic" fails to diagnose implicit int errors.
> I'm not sure whether this is a bug in gcc or in the way Windows
> versions of gcc are built.

In the case of Cygwin it is quite certainly a bug as Cygwin is not a
Windows target.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

SD adaptations for Waldorf Q V3.00R3 and Q+ V3.54R2:
http://Synth.Stromeko.net/Downloads.html#WaldorfSDada

--
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

* Re: g++ doesn't diagnose implicit int error
  2019-06-11 17:22   ` Achim Gratz
@ 2019-06-11 18:35     ` Brian Inglis
  0 siblings, 0 replies; 4+ messages in thread
From: Brian Inglis @ 2019-06-11 18:35 UTC (permalink / raw)
  To: cygwin

On 2019-06-11 11:22, Achim Gratz wrote:
> Keith Thompson writes:
>> On Windows targets (including Cygwin and MinGW), the "-fms-extensions"
>> option is enabled by default.  This option enables certain Microsoft
>> extensions -- and apparently inhibits any diagnostics for implicit int.
>>
>> It is unfortunate, and arguably a bug, that this means that
>> "g++ -std=c++11 -pedantic" fails to diagnose implicit int errors.
>> I'm not sure whether this is a bug in gcc or in the way Windows
>> versions of gcc are built.
> 
> In the case of Cygwin it is quite certainly a bug as Cygwin is not a
> Windows target.

Seems like ms-extensions is enabled if the target is x86 with MS ABI, or
plan9-extensions is enabled. The former allows use of struct/union member names
the same as typedef names, and the latter allows passing pointers to
structs/unions and typedefs with anonymous fields, and referring to anonymous
fields declared using typedefs.

Cygwin may require these extensions to handle Windows structure definitions in a
Windows compatible way, to allow compilation of the Windows C and C++ modules
under winsup. That it enables C++ implicit int is unfortunate.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.

--
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).