Constant Strings can't convert to int(or double) properly

These bugs do plan to be resolved, when they can be.

Moderator: GZDoom Developers

Constant Strings can't convert to int(or double) properly

Postby ZippeyKeys12 » Sat Nov 11, 2017 10:57 pm

Code: Select allExpand view
const x="12";
int y=x.ToInt();
console.printf("%d",y);
Prints 0
Code: Select allExpand view
int y="12".ToInt();
console.printf("%d",y);
Prints 0
But...
Code: Select allExpand view
String x="12";
int y=x.ToInt();
console.printf("%d",y);
Prints 12
I don't think this is intended, and while running ToInt() on a literal is pointless, some may want to run it on a constant.

EDIT: Also happens with ToDouble()
ZippeyKeys12
 
Joined: 15 Jun 2016

Re: Constant Strings can't convert to int(or double) properl

Postby Graf Zahl » Sun Jan 21, 2018 10:11 am

The compiler really accepts this? I am not surprised that it fails. To call a function you need to take the address of a variable. For a constant that's not possible at the moment.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Constant Strings can't convert to int(or double) properl

Postby Graf Zahl » Sun Jun 03, 2018 11:33 am

Moved to "on hold" because I really do not have any good idea how to deal with this.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany


Return to On Hold Bugs

Who is online

Users browsing this forum: No registered users and 0 guests