Skip to content

fmt: Printf, %s output of nil get poisoned by struct pointers  #3752

@gopherbot

Description

@gopherbot

by jakzale:

What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.
1. Print nil using %s placeholder after printing a structure  or a pointer using %s
placeholder
2. http://play.golang.org/p/0XwuksmHud

What is the expected output?
%!s(<nil>) %!s(*main.A=<nil>) %!s(<nil>) {} %!s(<nil>)

What do you see instead?
%!s(<nil>) %!s(*main.A=<nil>) %!s(*main.A=<nil>) {} %!s(main.B={})

Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?
Mac OSX 10.7.4

Which version are you using?  (run 'go version')
go version go1.0.2

Please provide any additional information below.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions