I have installed cygwin then I ran setup-x86_64.exe -q -P wget -P gcc-g++
and that installed gcc 5.4.0
But how can I install gcc 6.4.0 on cygwin?
Latest test (experimental) version is 6.3.0-2
https://cygwin.com/ml/cygwin-announce/2017-06/msg00079.html
All available experimental packages can be selected by pressing the Exp in the top right part of the chooser window. Be warned, however, that the next time you run setup.exe it will try to replace all old or experimental versions with the current version, unless told otherwise.
https://cygwin.com/cygwin-ug-net/setup-net.html#setup-packages