ICC ignores type on class variable definition

ICC ignores type on class variable definition

class A {
public:
 static int t;
};
char A::t;

ICC 13 update 1 on windows compiles this code, but mustn't.

BTW:

Why forum is too slow working?

Sometimes it gives:

Gateway Timeout

The proxy server did not receive a timely response from the upstream server.

7 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.

Yeh, I can see the issue. thanks for letting us know.

VC2010 and VC2012 will issue an error. icl issued a warning instead. I'll submit to the compiler to look at.

icl warning:
u361639.cpp(7): warning #147: declaration is incompatible with "int A::t" (declared at line  char A::t;

Not sure why the forum server is slow. If it still slow tomorrow, please let me know too.
Thanks!
Jennifer

A static member of a class, even if it is declared with a wrong type 'char', must be initialized with some default value, like:
...
class A
{
public:
static int t;
};
char A::t = 0;
...
So, it looks like there are actually two errors and I'll check what another C/C++ compilers will report. I raise a red-alert and errors like these once are simply not acceptible because the test-case is a classic one.

I'd like to provide results of additional verification.

Older version ( 12 ) of Intel C++ compiler also compiles the test-case and at least three test-cases could be considered:

[ Test-case 1 ]

class A
{
public:
static int t;
};

char A::t;

Intel C++ compiler:
Warning #147: declaration is incompatible with "int A::t" (declared at line 4344)
char A::t;
^

Microsoft C++ compiler:
Error C2371: 't' : redefinition; different basic types

Borland C++ compiler:
Error E2356 ... Type mismatch in redeclaration of 'A::t'
Error E2344 ... Earlier declaration of 'A::t'

MinGW C++ compiler:
Error: conflicting declaration 'char A::t'
Error: 'A::t' has a previous declaration as `int A::t'

Turbo C++ compiler:
Error ... Type mismatch in redeclaration of 'A::t'

[ Test-case 2 ]

class A
{
public:
static int t;
};

int A::t;

[ Test-case 3 ]

class A
{
public:
static int t;
};

int A::t = 0;

>>...Why forum is too slow working?

Please report any IDZ web-site related issues and problems at: http://software.intel.com/en-us/forums/watercooler-catchall and that forum is monitored by IDZ management.

Hello,

I've forwarded your feedback regarding the slow IDZ internally. We cannot promise to improve this in a sudden but at least the correct people are aware of it now.

Best regards,

Georg Zitzlsberger

This issue is fixed in 14.0 and later. Now ICL also emits the error:

test.cpp(6): error: declaration is incompatible with "int A::t" (declared at line 4)
  char A::t;
          ^

Jennifer

Laisser un commentaire

Veuillez ouvrir une session pour ajouter un commentaire. Pas encore membre ? Rejoignez-nous dès aujourd’hui