It is not legal to take GPL code and re-license it under CC-BY-SA, and fair-use is settled on a case-by-case basis in the US and may change from country to country. That means that it is not known to be legal to post GPL’d code to Stack Overflow or other stack exchange sites. See, for example, here, where the consensus is that you aren’t allowed to use GPL’d code in an answer on Stack Overflow.
For answers and most questions, this isn’t a problem. If you’re the original author of the code, you can dual-license it under GPL and CC-BY-SA and implicitly do so when posting it here.
However, suppose you are having trouble with some GPL software you didn’t write. You can create an MCVE which narrows down the specific issue, but only by bisecting the existing code instead of reproducing it in a separate project.
In most cases, you could then post your MCVE to Stack Overflow along with your question. However, since the code is GPL’d, you cannot post it in the question. Since questions for debugging help must include the code in the question, this means you cannot ask your question on SO at all.
I have in fact been told that questions about GPL’d code aren’t appropriate for SO for this reason. However, that seems completely wrong: a lot of important, and complicated, code is GPL’d. Preventing people from asking about this code is limiting for the site.
Therefore, the question: what should we do about this?
I have three suggestions:
- Relax the rules about posting GPL’d code. Allow it in questions when it seems clear it’ll qualify as fair use. This is probably safe, a) as most questions and answers probably fall under fair use*, b) most people who GPL their code are probably fine with it being put on SO or derivative works, and c) the site will probably get takedown requests before lawsuits. But if I’m wrong about both of those assumptions simultaneously (I am not a lawyer, copyright is complicated, international copyright is even more complicated, etc.), I think the site could have legal liability.
- Allow MCVEs to be links instead of code in the question, if there’s a licensing conflict, the link is to a place which will probably last a while (GitHub, savannah.nongnu.org, kernel.org, etc), and the relevant code is easy to find on the linked page (instead of “I get compiler errors on this 3000-line file”).
- EDIT to add: A third option is to allow portions of user-submitted content to be under other licenses than CC-BY-SA 3.0. That would probably present a technical challenge at least, and has other drawbacks; I doubt it would be worth doing, but I thought it would be worth mentioning for completeness.
- This is similar to what Jeff Atwood said about code originally posted on SO, but that was for using code in non-SO projects. I don’t know if we should be more paranoid ourselves, or if anything relevant has changed in the last 8 years.
printf("Hello world!\n");
as a code snippet, and licensed that snippet as GNU GPL, does that mean that nobody could ever use that line of code again, or is there some sort of way to say, legally "This snippet is too short / too common to be licensed."#include <readline/readline.h>
which is purely functional. You can't distribute the compiled product on SO, and every line in the MCVE would have been written by me.