Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7953 Discussions

virt-specifier after function declared like a variable is not recognized

Lesser__Nicolas
Beginner
406 Views

using F = void();

struct X {
  virtual F f;
};
 
struct Y : X {
F f override;
};
 
The code is valid, but ICC cannot compile the overriden function declaration in Y.
0 Kudos
5 Replies
Viet_H_Intel
Moderator
407 Views

Hi Nicolas,

What Intel compiler version did you use? and can you also let us know your command line options?

Thanks,

Viet 

0 Kudos
Lesser__Nicolas
Beginner
407 Views

Hi and thanks for responding! :)

Oh yeah, I forgot. So I'm using ICC 18.0.0 with no command flag options at all.

0 Kudos
Viet_H_Intel
Moderator
407 Views

I got the same error with Gnu7.3 and ICC 18.0

Can you confirm the error only seen with Intel Compiler and worked on GNU?

Thanks,

Viet 

$ icpc t2.cpp -c -std=c++17

t2.cpp(10): error: expected a ";"
  F f override;
      ^

compilation aborted for t2.cpp (code 2)
$ g++ t2.cpp -c -std=c++17
t2.cpp:10:3: error: expected ‘;’ at end of member declaration
 F f override;
   ^
 

0 Kudos
Lesser__Nicolas
Beginner
407 Views

This is also a gcc bug. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87174

Clang compiles the code just fine.

The code is well-formed, as a member-declarator is defined as ([class.mem]):

> member-declarator:

> - declarator virt-specifier-seq[opt] pure-specifier[opt]

Here, 'override' is a virt-specifier belonging to the virt-specifier-seq.

 

0 Kudos
Viet_H_Intel
Moderator
407 Views

I've reported this to the developer. The internal  bug is CMPLRS-52580

Thanks,

Viet 

0 Kudos
Reply