Skip to content

spec: taking address of a string literal #6031

@gopherbot

Description

@gopherbot

by bronze1man:

What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.
http://play.golang.org/p/aI6gKoGP_3

What is the expected output?
compilation should success.

What do you see instead?
prog.go:8: cannot take the address of []byte literal
prog.go:9: cannot take the address of string("a")
prog.go:10: cannot take the address of "a"
prog.go:11: cannot take the address of t1("a")

Please provide any additional information below.

http://golang.org/ref/spec#Address_operators
In the spec it not forbid to get an address of a string literal

But I can get an address of a string literal,and I do not need to care about free that
pointer.
        tmp:="a"
    fmt.Println(&tmp)
http://play.golang.org/p/B4Owwtsqn9

Just a syntactic sugar.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions