By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,421 Members | 1,128 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,421 IT Pros & Developers. It's quick & easy.

Pointer to array template parameter in partial specialization

P: n/a
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
Feb 21 '07 #1
Share this Question
Share on Google+
8 Replies


P: n/a
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
Feb 21 '07 #2

P: n/a
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 ?
Feb 21 '07 #3

P: n/a
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
Feb 21 '07 #4

P: n/a
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.
Feb 21 '07 #5

P: n/a
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
Feb 21 '07 #6

P: n/a
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?
Feb 22 '07 #7

P: n/a
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 ?
Feb 22 '07 #8

P: n/a
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
Feb 22 '07 #9

This discussion thread is closed

Replies have been disabled for this discussion.