- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, the following trivial program doesn't compile with icpc, but it's fine with g++ and clang++ :
[cpp] template< unsigned char S > class A { public: A(int a) : a(a) { } int a; }; class B : A< 's' > { public: B(int b) : A(b) { } }; [/cpp]
That explains some of the problems in http://software.intel.com/en-us/forums/topic/401384. Who is wrong, icpc, or g++ and clang++ ?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How about:
template< unsigned char S >
class A { public: A(int _a) : a(_a) { } int a; };
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Jim,
I don't see how that would change the outcome of the compilation (and in fact, it doesn't). The problem comes from "error: argument list for class template "A" is missing B(int b) : A(b) { }", but of course the argument of the class template "A" should (IMO) be inferred from the definition of class B. Hence I think icpc is wrong, and clang++ and g++ are right, but maybe this is not the case.
Changing the constructor of B to B(int b) : A<'s'>(b) { }, makes the file compilable, but it shouldn't be necessary to redefine the template argument again, right ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I do not see this issue with the 14.0 beta update 1. You can still download the beta update1. See this thread about the beta.
Jennifer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok thanks, I was indeed using icpc 13.1. Hopefully this will also fix compilation issues with g++ 4.8.1 headers, in the meantime, back to g++.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Sergey,
Your initial test case obviously won't compile with any of the compilers, since there is no default constructor for class B, and you have a line with "B b;", which implies a call to the default constructor.
Your last test case doesn't compile with icpc 13.1, but as Jennifer said, it should be fixed in 14.0. The error is still the same with icpc, "error: argument list for class template "A" is missing"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Source for stating that "g++ and clang++ are deviated from the C++ standard" for that example, please ?
"Cannot use template 'A' without specifying specialization parameters in function B::B(int)" <= well, that's the problem, the specialization parameter for 'A' is specified by the defintion of 'B' !
I attached an example for which I'm curious as to what Borland says about it. The intel compiler error says:
intel.cpp(16): error: "A" is not a nonstatic data member or base class of class "B"
B(int b) : A< 'd' >(b) { }
meaning that the compiler knows that the specialization parameter is not 'd'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Source for stating that "g++ and clang++ are deviated from the C++ standard" for that example, please ?
"Cannot use template 'A' without specifying specialization parameters in function B::B(int)" <= well, that's the problem, the specialization parameter for 'A' is specified by the defintion of 'B' !
I attached an example for which I'm curious as to what Borland says about it. The intel compiler error says:
intel.cpp(16): error: "A" is not a nonstatic data member or base class of class "B"
B(int b) : A< 'd' >(b) { }
meaning that the compiler knows that the specialization parameter is not 'd'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>> Source for stating that "g++ and clang++ are deviated from the C++ standard" for that example, please ?
GCC does support exntensions to the published standards and those extensions are listed in the GCC documentation. The extensions are enabled by default but you can control thier inclusion with the -std= flag. Legal options (in gcc 4.7.3) include c89,c90,c99,gnu89,gnu90,gnu99,c++98,c++0x,gnu++98,gnu++0x. The default standard for C code is gnu89 and for C++ code gnu++98 so by default the compiler will accept certain extensions to the standard.
Try compiling your code in g++ with -std=c++98 and see if it still compiles. That will narrow down if the problem is in standards compliance or with the compilers implementations of the standard.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Casey wrote:
>> Source for stating that "g++ and clang++ are deviated from the C++ standard" for that example, please ?
GCC does support exntensions to the published standards and those extensions are listed in the GCC documentation.
That is why I was asking for a source on the C++ standard about that specific example, not about the compiler itself, sorry if it was not clear. (btw, it also compiles with c++98)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sergey Kostrov wrote:
>>...I attached an example for which I'm curious as to what Borland says about it...
..\Tests>bcc32.exe intel.cpp
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
intel.cpp:
Error E2312 intel.cpp 16: 'A<100>' is not an unambiguous base class of 'B' in function B::B(int)
Error E2251 intel.cpp 16: Cannot find default constructor to initialize base class 'A<115>' in function B::B(int)
*** 2 errors in Compile ***You're Not arguing with me ( have you ever used Borland C++ compiler? ) and I see that GCC and Clang teams are trying to "undermine" some fundamental features of C++ language and, unfortunately, I can't justify such deviations. I regret to see that Intel C++ compiler team follows that wrong path. It would be nice to see additional information on why they decided to support it by default without creating additional compiler flags, like '-full-clang-compatibility' or '-full-gcc-compatibility' ( similar to an option to provide a full compatibility with Microsoft C++ compiler ).
Note: Please download Borland C++ compiler version 5.5.1 for all the rest verifications on your side(s).
Sergey, I would like to assure you that I'm not arguing with you in any way. I just want to understand the problem here. What is not clear from my side, is that you are saying that G++ and clang++ (and now icpc) are violating the C++ standards. My previous question was then to naturally ask for a "proof" of that violation, by just giving me a pointer to the standards about that specific example. Do you have such a pointer, or are you just inferring that there is a violation because the Borland compiler can't compile the example ?
Thanks a lot for your help and time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page