On Sun, Apr 19, 2009 at 7:19 PM, James Dennett <james.denn...@gmail.com> wrote:
> On Sun, Apr 19, 2009 at 4:15 PM, Paolo Piacentini
> <paolopi...@hotmail.com> wrote:
>> I don't think this is a bug but certainly it is a problem.
>>
>> Would you please consider it and let me know? I hope so. Thanks.
>>
>> The following simple volcalc.cpp code compiles with no errors (and
>> works) in Windows Visual C++.
>> It simply sizes the "alldata" array later in the code.
>
> If Visual C++ does not diagnose the error in the code in its best
> standards-conforming mode, that is a bug in Visual C++.  Allowing it
> as an extension is an entirely reasonable thing to do though.
>
>> With g++ v.4.3.2 instead I get the error reported hereby.
>> For some reason it does not like the fact that struct is declared
>> local.
>
> That is what C++ requires; template parameters must have external
> linkage, and in C++98 local types do not have external linkage.
>
>> If you declare struct as global it will be working but I cannot
>> change the code so drastically.
>>
>> I would thankfully appreciate any help (including tough critics to the code).
>
> The "drastic" change would be needed to make your code valid C++, and
> if you do that then g++ will compile it.
>
> There has been discussion of changing this rule for the next C++
> standard, see e.g.,
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2402.pdf
> though I don't see signs of it having been merged into the current
> committee draft.  N2402 does mention the change in MSVC++ as being a
> relatively recent extension.  A quick search hasn't turned up the
> current status of N2402, though there was some discussion of weakening
> it by removing support for using unnamed types as template parameters,
> and it seemed to have reasonably strong support in that form.

Asking around a little more, and I've been pointed to
  http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm
which has been incorporated into the current committee draft for
C++0x, and allows use of local types as template parameters.  It looks
like your code will become legal in the next C++ standard, and g++
might well start supporting this before then (if someone is inspired
to implement it, that is).

-- James

Reply via email to