[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
Title: | C++ |
Notice: | Read 1.* and use keywords (e.g. SHOW KEY/FULL KIT_CXX_VAX_VMS) |
Moderator: | DECCXX::AMARTIN |
|
Created: | Fri Nov 06 1987 |
Last Modified: | Thu Jun 05 1997 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 3604 |
Total number of notes: | 18242 |
3604.0. "Difference / problem ? instantiating nested templates in 5.6?" by CREME::LAMPERT (Pat Lampert, UNIX Applications Support, 343-1050) Wed Jun 04 1997 21:56
A customer who recently was made a c++ field test site for 5.6 because
of a segv problem in the 5.5 compiler has called back into the customer
support center seeking assistance with a problem they are having
instantiating nested templates with friends under 5.6 The same code
seemed to instantiate properly under 5.5.
Customer information:
Company : MACDONALD DETWEILER
Contact : KEITH BECKETT
Phone : (604)278-3411
------------
Anyway. I have not been able to reproduce this in a small program so I
had the customer send me the entire pre-processed source from the module
where he is having the problem. It is a bit too big to post, so I will
provide a pointer to it after I describe what is happening.
When I compile the the source under 5.6 some of the templates instantiate,
but others dont. The ones that fail appear to all be cases of templates
that contain templates with friends.
For example:
Only the following types are instantiated...
------------------------------------------------
void static __dummy_ (int p1, SelfRecord *p2, BARRAY<double, (const int)1,
(const int)3 > &p3)
void static __dummy_ (int p1, SelfRecord *p2, BARRAY<float, (const int)0,
(const int)5 > &p3)
void static __dummy_ (int p1, SelfRecord *p2,
BARRAY<dc_location_param_type, (const int)1, (const int)32 > &p3)
void static __dummy_ (int p1, SelfRecord *p2,
BARRAY<off_nadir_mirror_fcn_type_rec, (const int)3, (const int)93 > &p3)
------
Yet the source has many other instancaes of BARRAY. For example:
typedef BARRAY<double,1,3> EAR_EcrCoord;
typedef BARRAY<SEN_SpectralBandsPlusNull,1,SEN_MaxSpectralBands>
spectral_band_a
typedef BARRAY<BOOLEAN,1,SEN_MaxSpectralBands> SEN_SpectralBandList;
typedef BARRAY<SEN_EtmBandAdNumber,1,SEN_MaxSpectralBands>
SEN_EtmBandAdNumberAr
typedef
BARRAY<SEN_EtmBandAdNumberArray,senc_null_sensor_mode,senc_max_sensor_modes>
SEN
typedef BARRAY<double,1,max_alignment_axis> alignment_vector_type;
typedef BARRAY<alignment_vector_type,1,max_alignment_axis>
alignment_matrix_type
typedef BARRAY<float,0,max_polynom_order> polynom_order_array;
etc etc...
Why dont these instantiate?
-------------
Since I dont have the original sources and header files I asked the customer
how he builds this thing. He says he is using automatic instantiation, but
he doesnt seem to be following the rules layed out in the manual in chapter 5.
instead of creating separate template declaration and template definition files
he is inlining the definition in the header.
I then pointed him to the documentation (which he admits he had not read!)
After reading chapter 5 he emailed the following comments. I am not sure
if what he says is valid of not.
From: Keith Beckett <[email protected]>
Message-Id: <[email protected]>
To: [email protected]
Subject: Re: template problems with cxx V5.6
X-Sun-Charset: US-ASCII
Hi Pat,
Thank you for the info. This seems to be providing information which is not
included on the cxx man pages!
I understand the point of view that this information is taking in that it has
assumed that we have separated the template declaration from the template
definition, storing them in separate files. However, experience has shown us
that this approach leads to the many problems that we are now experiencing
with the 5.6 cxx compiler. By inlining the template method bodies, we have
effectively said to the compiler, here is everything that you need to know
about instantiated the templated object. Therefore, there should be no need
to refer back to it later at link time. This approach has worked well on all
of the other platforms that we deal with (IBM, SGI, SUN), as well as the 5.5
cxx compiler!
I am still looking into this issue as well from our end. What has occurred
to me is that the 5.6 cxx compiler is having difficulty instantiating nested
templates!
For example:
typedef BARRAY<float,1,10> vector;
typedef BARRAY<vector,5,14> array;
int SelfConvertBARRAY2(int,SelfRecord*,array)
where BARRAY is a templated class and SelfConvertBARRAY2 is a templated free
function that calls SelfConvertBARRAY the appropriate number of times for
each of the 5:14 elements of type vector in array.
It appears that the 5.6 cxx compiler is no longer instantiating the
SelfConvertBARRAY, whereas the 5.5 cxx compiler did instantiate this for us.
I hope this helps you out a bit!
Cheers, Keith
-------------------------------------
Keith is correct; in that if I compile the proprocessed file with 5.5
I get different results than 5.6. Also, using the -tused switch under
5.5 leaves no repository, while under 5.6 I get a repository.
If you want to see the actual file you can get it as follows:
ftp decatl.alf.dec.com
login:anonymous
password: "your email addr"
ftp> cd pub
ftp> get md.txt
Thanks,
Pat Lampert CSC Atlanta
T.R | Title | User | Personal Name | Date | Lines |
---|
3604.1 | | DECCXX::MITCHELL | | Thu Jun 05 1997 19:22 | 2 |
| Since they are a field test site, we'll handle this as
a field test issue.
|