See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=49901 for an explanation. It's partially the macro itself that is buggy:
Indeed. I'm merging these bugs, although there is only a little that can be done on the automake side, as far as I can see. --thanks, karl.