Build of gcc and qt5 either run forever or run for many hours until the build stops working. If it fails, it simply gives the last few lines of what appears to be a normal build process. This was a fresh install of homebrew on a fresh OS install of Sierra.
brew update and retried your prior step?brew doctor, fixed as many issues as possible and retried your prior step?sudo chown -R $(whoami) $(brew --prefix)?brew gist-logs <formula>
gcc: https://gist.github.com/267756fd0fb7ef075b14b488ed86c2e0
qt5: https://gist.github.com/da49c5cd0e1b42eab9809cd4967f0f9f
Assuming they may be related, so posting both of them.
GCC shouldn't be a problem, install CLT (sudo xcode-select --install) and try again.
Qt5 problem is known and tracked in multiple places, notably #1705 #4841.
"run forever": use brew install foo --verbose to monitor progress.
Got it. Don't know how I missed that, sorry for the noise.