Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
7679 Discussions

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

Lesser__Nicolas
Beginner
163 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
164 Views

Hi Nicolas,

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

Thanks,

Viet 

Lesser__Nicolas
Beginner
164 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.

Viet_H_Intel
Moderator
164 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;
   ^
 

Lesser__Nicolas
Beginner
164 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.

 

Viet_H_Intel
Moderator
164 Views

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

Thanks,

Viet 

Reply