We require that the asker posts code that they have written themselves. In that case it can be assumed that the asker owns the copyright for that code and can license that code to Code Review under CC-BY-SA. For this it is irrelevant whether that code was already published elsewhere under a different license; one creative work can be dual-licensed under multiple licenses.
If the poster were not the author of the whole code in question and would therefore not be the exclusive copyright holder for the whole code, then the poster must have the right to sublicense the part of the code not written by them. Sublicensing is generally allowed in the more liberal licenses such as various BSD or MIT variants, but is restricted by the GPL. As a result, the various CC licenses are generally incompatible with the various GPL versions.
Freddy has forked a GPL-licensed project on GitHub. He refactors a part of the project and wants Code Review to criticise the refactored code.
This is not OK: The refactored code is a derivative work of GPL code, and cannot therefore be licensed under an incompatible license such as CC-BY-SA without the (written) consent from all contributors for the code in question.
Variant: The project used a liberal license such as a BSD license variant. Then, Freddy may re-license that code under CC-BY-SA as long as the terms of the original license are still respected – i.e. the original license header is included in the question.
Annie has created a new project and published it on Bitbucket. She posts an interesting part on Code Review for it to get some feedback.
This is OK: The license is wholly irrelevant since the copyright holder may republish the work under a different license.
Variant: The project has attracted additional contributors, and their contributions have been merged. Then, this is to be treated as if Annie had forked a pre-existing project, and the project's license becomes relevant.
Less Simple Examples:
Julia has written some code for her employer which is published under the GPL (or really, any other license, or not published at all). She wants a code review for that code from this site.
This is probably not OK. Employment contracts frequently feature copyright assignment to the employer. Therefore, Julia is not the copyright holder and can't issue a license for that code. Julia's employer would have to explicitly consent to the code being republished under an incompatible license.
Variant: The code was published by the employer under an MIT license. Then anyone including Julia may sublicense the code.
Max has added a feature to a GPL-licensed open-source project. Before he issues a pull request, he wants some feedback from this site, but only for one function he completely wrote from scratch.
This is pretty tricky. The new feature will likely depend on the other (GPL-licensed) parts of the project and would therefore have to be GPL-licensed itself. Even though the function was written from scratch, it would likely constitute a derivative work since it's useless without the rest of the project. As a result, the code could probably not be posted on Code Review.
Variant: The project used a BSD license. Then Max may post his code to get feedback.
To do: contemplate CC-BY-SA ↔ LGPL compatibility.