After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 548550 - The end_ptr parameter of the string.to_double should be weak.
The end_ptr parameter of the string.to_double should be weak.
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Bindings
0.3.x
Other All
: Normal normal
: ---
Assigned To: Jürg Billeter
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2008-08-19 22:32 UTC by rainwoodman
Modified: 2008-09-16 13:52 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
A patch (739 bytes, patch)
2008-08-19 22:33 UTC, rainwoodman
committed Details | Review

Description rainwoodman 2008-08-19 22:32:37 UTC
Please describe the problem:
The end_ptr parameter of the string.to_double should be weak.
Because strtod doesn't create any new string.

Steps to reproduce:
This code should work.

        protected override void from_string(string str){
            weak string s = str;
            weak string end_ptr = null;
            int dimensions = 0;
            while(true) {
                s.to_double(out end_ptr);
                if((void*) s == (void*) end_ptr) break;
                s = end_ptr;
                dimensions ++ ;
            }
            this.dimensions = dimensions;
            s = str;
            for(int i = 0; i< dimensions; i++){
                positions[i] = s.to_double(out s);
                dimensions ++ ;
            }
        }

But ends up with 
libgdakit/temp.vala:70.17-70.27: error: Invalid assignment from owned expression to unowned variable
                                s.to_double(out end_ptr);
                                            ^^^^^^^^^^^
libgdakit/temp.vala:78.32-78.36: error: Invalid assignment from owned expression to unowned variable
                                positions[i] = s.to_double(out s);
                                                           ^^^^^
Compilation failed: 2 error(s), 0 warning(s)


Actual results:


Expected results:


Does this happen every time?
Yes

Other information:
A workaround is to declare the strings as 'strong'. But it ends up with a messy ccode that duplicate the strings for many times.
Comment 1 rainwoodman 2008-08-19 22:33:20 UTC
Created attachment 117011 [details] [review]
A patch
Comment 2 Jürg Billeter 2008-09-16 13:52:21 UTC
2008-09-16  Jürg Billeter  <j@bitron.ch>

	* vapi/glib-2.0.vapi:

	Fix strtod, strtoul, and g_ascii_strtoll bindings,
	patch by Yu Feng, fixes bug 548550

Fixed in r1773.