Skip to content

text/template: constant overflows int in template engine for 386 builds #25833

Closed
@arkadiam

Description

@arkadiam

What version of Go are you using (go version)?

go version go1.10.3 linux/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="linux"

Bug exists when program built as:
env GOOS=linux GOARCH=386 go build
AND
env GOOS=linux GOARCH=386 GO386=387 go build
AND when run in GoPlayground

It works correct in amd64 architecture environment.

What did you do?

I'm trying to compare time.Duration variable with the constant in text/template.

Variable:
duration := 10*time.Minute
Template:
{{if gt . 60000000000}}true{{else}}false{{end}}

If the code is build for 386 architecture it fails with run-time error:
template: :1:10: executing "" at <60000000000>: 60000000000 overflows int

It fails in GoPlayground too:

https://play.golang.org/p/frPKxFsZKE6

What did you expect to see?

template engine should properly evaluate constants like 60000000000 for 386 builds

What did you see instead?

60000000000 overflows int

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions