Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Another difference between gcc and clang

50 views
Skip to first unread message

Juha Nieminen

unread,
Nov 1, 2016, 3:07:10 AM11/1/16
to
This piece of code, by itself, does not cause a compiler error with gcc6,
but does with clang:

//-------------------------------------------
template<typename T>
class C
{
public:
test(int, int);
};
//-------------------------------------------

clang says:
error: C++ requires a type specifier for all declarations

gcc says nothing and just accepts it. I wonder what it's thinking.

--- news://freenews.netfront.net/ - complaints: ne...@netfront.net ---

Alf P. Steinbach

unread,
Nov 1, 2016, 6:50:14 AM11/1/16
to
On 01.11.2016 08:06, Juha Nieminen wrote:
> This piece of code, by itself, does not cause a compiler error with gcc6,
> but does with clang:
>
> //-------------------------------------------
> template<typename T>
> class C
> {
> public:
> test(int, int);
> };
> //-------------------------------------------
>
> clang says:
> error: C++ requires a type specifier for all declarations
>
> gcc says nothing and just accepts it. I wonder what it's thinking.

It's thinking "implicit int".

That's never been part of C++.


Cheers!,

- Alf


Joost

unread,
Nov 2, 2016, 12:08:40 PM11/2/16
to
Juha Nieminen <nos...@thanks.invalid> wrote:
> This piece of code, by itself, does not cause a compiler error with gcc6,
> but does with clang:
>
> //-------------------------------------------
> template<typename T>
> class C
> {
> public:
> test(int, int);
> };
> //-------------------------------------------
>
> clang says:
> error: C++ requires a type specifier for all declarations
>
> gcc says nothing and just accepts it. I wonder what it's thinking.

Did something change? The ancient 4.8.4 I have to use says this:

error: ISO C++ forbids declaration of 'test' with no type [-fpermissive]

which looks useful enough to me.

Christian Gollwitzer

unread,
Nov 2, 2016, 12:12:35 PM11/2/16
to
Am 02.11.16 um 17:08 schrieb Joost:
Maybe the error does not occur until you try to instantiate the
template? (I've got no current gcc to check now)

Christian


Öö Tiib

unread,
Nov 2, 2016, 1:38:07 PM11/2/16
to
gcc version 6.1.0 is also complaining like that so it is unsure what gcc6
OP is using and with what options.
0 new messages