All contributions to the Stack Exchange Websites are released under the Creative Commons Attribution-ShareAlike License (CC-BY-SA), either version 2.5, 3.0, or 4.0 depending on the post date. This applies to both code and other text in questions and answers. Code released under this license can be used under version 4 of the CC-BY-SA (while the original code remains under the older version if released as such) and can be combined with the General Public License (GPL) version 3.
However, Creative Commons recommends not using any of their licenses with software, because "Patent and trademark rights are not licensed under" them (the CC-BY-SA legal code). This means that a user could post a question or an answer with code to a Stack Exchange site and even if another user uses that code in a project licensed under the GPL version 3 and completely complies with the requirements of both licenses, the first user could sue the second user for patent infringement through a submarine patent.
For those who want to integrate Stack Exchange code in their GPL projects, is there anything they can do to protect themselves from possible patent trolling from the originators of the code on the Stack Exchange sites? I don't think this is likely to happen, but you can never be too careful with software licensing.