It may be a bug: the code (in org-html-src-block) looks like this
(label (let ((lbl (and (org-element-property :name src-block)
(org-export-get-reference src-block info))))
(if lbl (format " id=\"%s\"" lbl) ""))))
and I'm wondering whether the "and" should be an "or".