From: Giovanni Dicanio on
"Adam" <adam_mich(a)gazeta.pl> ha scritto nel messaggio
news:95879f74-8a60-43af-9483-0bac824a61aa(a)t20g2000yqe.googlegroups.com...

> Of course I should use STL containers.

Note that there are quality programmers here that don't like STL containers.

While there could be some rough edges in STL container public interfaces
(for example std::map does not use ordinary 'key' and 'value' terms to
identify map keys and values, but it uses instead 'first' and 'second', kind
of more obscure), truth to be told: I've never found a C++ library offering
containers with a greater level of composibility than STL.

Note that STL containers can host also convenient MFC classes like CString.

> It is old, legacy code
> which uses CArray<>. I've just added one member - stdext::hash_map
> and got those Access Violation errors.

As written in my previous post, I think that those errors are caused by
iterator debugging feature of STL.
There could be two cases here:

1. There could be a bug in iterator debugging feature, so you have a false
positive. Disabling _HAS_ITERATOR_DEBUGGING shuts down the false positive.

2. There could be an actual problem in using hash_map inside CArray
container, and iterator debugging is helping you, warning about that
problem.

I don't have the required familiarity with Microsoft's STL implementation to
be able to say you with certainity which of the above is true.
If I were you, I would trust STL's _H.I.D., and would get rid of CArray
storing the hash_map, and use std::vector instead.
I think that using std::vector instead of CArray would increase the quality
of your code.

My 2 cents,
Giovanni



From: Adam on
> These could be error messages generated by the Iterator Debugging feature of
> Microsoft VC++'s STL implementation.

In fact. In VS2005 SP1 Vista it starts to crash in a different place,
so _SECURE_SCL has also be set to 0.

#define _SECURE_SCL 0
#define _HAS_ITERATOR_DEBUGGING 0

It solves(?) the problem.

Thanks,
Adam
From: Giovanni Dicanio on
"Adam" <adam_mich(a)gazeta.pl> ha scritto nel messaggio
news:8e5420ef-ab34-4c5c-975e-860b9e114b99(a)c16g2000yqd.googlegroups.com...

>> These could be error messages generated by the Iterator Debugging feature
>> of
>> Microsoft VC++'s STL implementation.
>
> In fact. In VS2005 SP1 Vista it starts to crash in a different place,
> so _SECURE_SCL has also be set to 0.
>
> #define _SECURE_SCL 0
> #define _HAS_ITERATOR_DEBUGGING 0
>
> It solves(?) the problem.

I'm not sure it actually solves the problem...

My understanding is that both _SECURE_SCL and _HAS_ITERATOR_DEBUGGING should
help the programmer preventing shooting his own foot.

I'm more oriented in thinking that there could be subtle bugs that may arise
in using STL containers inside MFC's CArray.

I'll let you know if I have some more information...

Giovanni


From: Giovanni Dicanio on
"Giovanni Dicanio" <giovanniDOTdicanio(a)REMOVEMEgmail.com> ha scritto nel
messaggio news:#$kXYmGwKHA.5940(a)TK2MSFTNGP02.phx.gbl...

> I'll let you know if I have some more information...

A small update: I've just tried in VS2010 RC, and the code runs fine (no
access violation).

Giovanni


From: Tom Serface on
I am really impressed with 2010 RC so far. It's working with everything
I've tried and I like the new look and feel. The editor is even faster now.
All things considered I think this version looks like a good upgrade.

Tom

"Giovanni Dicanio" <giovanniDOTdicanio(a)REMOVEMEgmail.com> wrote in message
news:e$9NudHwKHA.3952(a)TK2MSFTNGP06.phx.gbl...
> "Giovanni Dicanio" <giovanniDOTdicanio(a)REMOVEMEgmail.com> ha scritto nel
> messaggio news:#$kXYmGwKHA.5940(a)TK2MSFTNGP02.phx.gbl...
>
>> I'll let you know if I have some more information...
>
> A small update: I've just tried in VS2010 RC, and the code runs fine (no
> access violation).
>
> Giovanni
>
>