The following template specialization construct is rejected by g++ 4.1.2
while icc 9.1 silently accepts is (even with -strict-ansi). Which
compiler is correct?
template<typename T>
struct x {};
template<typename T, unsigned N>
struct x<T*[N]{};
int main() {
x<inta;
x<int*[10]b;
return 0;
}
bashg++-4.1.2 -c tst.cpp
tst.cpp:7: error: template parameters not used in partial specialization:
tst.cpp:7: error: ‘T’
bashicc -strict-ansi -o tst tstst.cpp
bash>
thanks
/Oskar 8 3072
Oskar Enoksson wrote:
The following template specialization construct is rejected by g++
4.1.2 while icc 9.1 silently accepts is (even with -strict-ansi).
Which compiler is correct?
I wanted to say that the code was fine, but went to check with Comeau
online, and it confirmed that -- the code is accepted.
>
template<typename T>
struct x {};
template<typename T, unsigned N>
struct x<T*[N]{};
int main() {
x<inta;
x<int*[10]b;
return 0;
}
bashg++-4.1.2 -c tst.cpp
tst.cpp:7: error: template parameters not used in partial
specialization: tst.cpp:7: error: ‘T’
bashicc -strict-ansi -o tst tstst.cpp
bash>
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Oskar Enoksson wrote:
The following template specialization construct is rejected by g++ 4.1.2
while icc 9.1 silently accepts is (even with -strict-ansi). Which
compiler is correct?
template<typename T>
struct x {};
template<typename T, unsigned N>
struct x<T*[N]{};
int main() {
x<inta;
x<int*[10]b;
return 0;
}
bashg++-4.1.2 -c tst.cpp
tst.cpp:7: error: template parameters not used in partial specialization:
tst.cpp:7: error: ‘T’
Looks like a serious gcc bug to me.
Did you file it with the gcc people ?
Gianni Mariani wrote:
Oskar Enoksson wrote:
>The following template specialization construct is rejected by g++ 4.1.2 while icc 9.1 silently accepts is (even with -strict-ansi). Which compiler is correct? template<typename T> struct x {};
template<typename T, unsigned N> struct x<T*[N]{};
int main() { x<inta; x<int*[10]b; return 0; } bashg++-4.1.2 -c tst.cpp tst.cpp:7: error: template parameters not used in partial specialization: tst.cpp:7: error: 'T'
Looks like a serious gcc bug to me.
Did you file it with the gcc people ?
Oh, and I just noticed (and read carefully) the subject of your
message, Oskar, and wanted to tell you that
T*[N]
is NOT a pointer to array, but rather an array of pointers to T.
A pointer to an array would be
T(*)[N]
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Victor Bazarov wrote:
....
is NOT a pointer to array, but rather an array of pointers to T.
A pointer to an array would be
T(*)[N]
gcc accepts that type parameter for X. It's still a bug for gcc however.
Gianni Mariani wrote:
Victor Bazarov wrote:
...
>is NOT a pointer to array, but rather an array of pointers to T. A pointer to an array would be
T(*)[N]
gcc accepts that type parameter for X. It's still a bug for gcc
however.
:-) I wasn't arguing that it wasn't a bug...
V
Victor Bazarov wrote:
Gianni Mariani wrote:
>Oskar Enoksson wrote:
>>The following template specialization construct is rejected by g++ 4.1.2 while icc 9.1 silently accepts is (even with -strict-ansi). Which compiler is correct? template<typename T> struct x {};
template<typename T, unsigned N> struct x<T*[N]{};
int main() { x<inta; x<int*[10]b; return 0; } bashg++-4.1.2 -c tst.cpp tst.cpp:7: error: template parameters not used in partial specialization: tst.cpp:7: error: 'T'
Looks like a serious gcc bug to me.
Did you file it with the gcc people ?
Oh, and I just noticed (and read carefully) the subject of your
message, Oskar, and wanted to tell you that
T*[N]
is NOT a pointer to array, but rather an array of pointers to T.
A pointer to an array would be
T(*)[N]
V
Yes ok thanks. This bug surprised me - it's a simple construct. I
thought g++ was pretty stable.
I've created a bug report on the gcc bugzilla site.
BTW Bugzilla crashed when creating the bug report, so I also reported a
bugzilla bug to the bugzilla maintainers in an email. If this email
bounces I give up. Am I just unlucky or is the free software
infrastructure deteriorating?
Oskar Enoksson wrote:
....
BTW Bugzilla crashed when creating the bug report, so I also reported a
bugzilla bug to the bugzilla maintainers in an email. If this email
bounces I give up. Am I just unlucky or is the free software
infrastructure deteriorating?
This could be a regression in the gcc 4.X series. The gcc 3.4.4
compiler seems to work with this.
If it was a heavily used construct, it would have been fixed already.
However, I was a little surprised.
BTW - what's the bug ID ?
Gianni Mariani wrote:
Oskar Enoksson wrote:
...
>BTW Bugzilla crashed when creating the bug report, so I also reported a bugzilla bug to the bugzilla maintainers in an email. If this email bounces I give up. Am I just unlucky or is the free software infrastructure deteriorating?
This could be a regression in the gcc 4.X series. The gcc 3.4.4
compiler seems to work with this.
If it was a heavily used construct, it would have been fixed already.
However, I was a little surprised.
BTW - what's the bug ID ?
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30924
/Oskar This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Agent Mulder |
last post by:
Hi group,
I have a problem with partial template specialization. In the code
below I have a template struct Music with one method, play(),
and three kinds of music, Jazz, Funk and Bach. When I...
|
by: Walt Karas |
last post by:
The following gives an error in the declaration of the
member function x() of the class template Tpl, compiliing
with a recent version of GCC under Solaris:
class A { };
class B { };
...
|
by: BekTek |
last post by:
I'm still confused about the template partial specialization which is used
in many libraries..
due to lack of introduction for beginner..
Could you tell me about that in short?
Thanks in...
|
by: Imre |
last post by:
Please take a look at the following code:
template <typename T, typename Enable = void>
class A
{
public:
enum { value = 0 };
};
template <typename T>
|
by: Michael Stembera |
last post by:
Here is a very simple piece of code to repro this bug.
template<typename T, int N> inline bool foo( void )
{
return true;
}
template<typename T> inline bool foo<T, 1>( void )
{
return...
|
by: lhr_cool_guy |
last post by:
C++ doesn't allow partial specialization of function templates. I want
to know why this is so? Is the concept of function template partial
specialization not well defined? I have a case where I...
|
by: Marek Vondrak |
last post by:
Hello.
I have written the following program and am curious why it prints "1" "2".
What are the exact effects of explicitly providing function template
parameters at the call? Is the second...
|
by: Andre Kempe |
last post by:
hej folks.
i have a heap with fixed size and want to determine the depth of a
element with given index at compile-time. therefore i wrote some
templates. however, when i use template...
|
by: flopbucket |
last post by:
Hi,
I want to provide a specialization of a class for any type T that is a
std::map.
template<typename T>
class Foo
{
// ...
};
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |