I realized that hfill only flushes the first word to the right if the line started with the second half of a syllabification. If there is a manual linebreak afterwards the problem does not occure:
\documentclass{article}
\begin{document}
This is a very long sentence such that there has to be a point where a stu\-pendous line should be cut. \hfill test 123
This is a very long sentence such that there has to be a point where a stu\-pendous line should be cut. \hfill test 123\\
This is a very long sentence such that there has to be a point where this line should be cut. \hfill test 123
\end{document}
produces this:
This is a problem since I use hfill after quotes to give the author and date. Is there a reason for this behavior, is this a bug? I tested it with texlive 2017 and miktex 2.9.6300.
\hfillalone is not the best way for doing the job. – egreg Oct 20 '17 at 12:23~instead of spaces; you'll still have a problem if the "final" phrase won't fit on the line. some additional information here: Line break causes right alignment and Manual linebreak with justification but without empty line afterwards – barbara beeton Oct 20 '17 at 13:23