On Tue, Feb 21, 2017 at 9:13 PM, Alexander Kapshuk <alexander.kaps...@gmail.com> wrote: > On Tue, Feb 21, 2017 at 7:51 PM, Manlio Perillo > <manlio.peri...@gmail.com> wrote: >> I have noted that the intValue (and uintValue) Set method do the following: >> v, err := strconv.ParseInt(s, 0, 64) >> >> However this is incorrect on 32 bit systems: >> https://play.golang.org/p/tvAUCI63x3 >> >> Can this be considered a bug? >> >> Another, minor, issue is that: >> *i = intValue(v) >> return err >> >> i is set to 0 in case of error, discarding the default value. >> It is probably not an issue with the flag package, but probably should be >> corrected. >> >> >> Thanks >> Manlio >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-nuts+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. > > Looks like 'v' gets truncated towards zero when cast to int, which is > at least 32 bits in size, https://golang.org/pkg/builtin/#int. > > Declaring '*i' as type int64 retains the value of 'v' in '*i'. > https://play.golang.org/p/Cgg9itErt9
int(int64) conversion overflows int. https://play.golang.org/p/HMuFVDaPfr Output: tmp/sandbox655723034/main.go:9: constant 8589934592 overflows int -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.