Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » U++ community news and announcements » Index constructor from Vector now explicit
Index constructor from Vector now explicit [message #39196] Tue, 26 February 2013 20:02 Go to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Today I have encountered pretty tricky issue:

VectorMap<String, String> h;
const Index<String>& x = h.GetKeys();

This innocent looking code is broken in a very tricky way: GetKeys returns a reference to Vector<String> which is then picked by Index constructor to perform a conversion to Index<String> (in reality, there should have been h.GetIndex() instead...).

Because I have spent some bad amount of time trying to figure out what is happening, I have decided to disallow this conversion path by making Index constructor from Vector explicit. Now this will probably break some code (but not much of it), e.g. in theide, following line is now invalid:

Index<String> x = Split("hello;world", ';');

and has to be rewritten as

Index<String> x(Split("hello;world", ';'));

but I think it is still better to make this issue safer...

Mirek
Re: Index constructor from Vector now explicit [message #39197 is a reply to message #39196] Tue, 26 February 2013 23:49 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3357
Registered: August 2008
Senior Veteran
Hello Massimo and Mirek

ProtectDB.cpp, line 268 gives a compiling error.


Best regards
Iñaki
Re: Index constructor from Vector now explicit [message #39201 is a reply to message #39197] Wed, 27 February 2013 07:59 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
koldo wrote on Tue, 26 February 2013 17:49

Hello Massimo and Mirek

ProtectDB.cpp, line 268 gives a compiling error.


Fixed.

Mirek
Re: Index constructor from Vector now explicit [message #39210 is a reply to message #39196] Thu, 28 February 2013 12:42 Go to previous messageGo to next message
mdelfede is currently offline  mdelfede
Messages: 1307
Registered: September 2007
Ultimate Contributor
mirek wrote on Tue, 26 February 2013 20:02

Today I have encountered pretty tricky issue:

VectorMap<String, String> h;
const Index<String>& x = h.GetKeys();

This innocent looking code is broken in a very tricky way: GetKeys returns a reference to Vector<String> which is then picked by Index constructor to perform a conversion to Index<String> (in reality, there should have been h.GetIndex() instead...).

Because I have spent some bad amount of time trying to figure out what is happening........
Mirek


Eh... I stumbled on this error some time ago, and it took me a whole day to figure it out Smile
Good idea to fix it Smile
Re: Index constructor from Vector now explicit [message #39218 is a reply to message #39210] Fri, 01 March 2013 08:12 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3357
Registered: August 2008
Senior Veteran
Hello Massimo

It is strange. This problem appeared few days ago.

Is it really the same problem or perhaps Mirek has solved two problems? Smile


Best regards
Iñaki
Re: Index constructor from Vector now explicit [message #39220 is a reply to message #39218] Fri, 01 March 2013 09:00 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
koldo wrote on Fri, 01 March 2013 02:12

Hello Massimo

It is strange. This problem appeared few days ago.

Is it really the same problem or perhaps Mirek has solved two problems? Smile


I guess you misunderstand. The problem (that I and Massimo have encountered) was _resolved_ few days ago, but fix was not backward compatible, which resulted in issue in ProtectDB.cpp.

Still we both agree that in this very case, minor BW incompatibility is better.

Mirek

[Updated on: Fri, 01 March 2013 09:01]

Report message to a moderator

Previous Topic: HttpRequest added remaining HTTP methods
Next Topic: .ini file parser refactored
Goto Forum:
  


Current Time: Fri Apr 26 00:52:43 CEST 2024

Total time taken to generate the page: 0.07194 seconds