Training at work regarding software licensing instructed us that we should not use code from any project using a license that requires sharing modifications such as the GPL. We can use Linux as an OS for example, but we can't make a change to the kernel to support a work project since that would require sharing that change in code form. We can use LGPL libraries, MIT-licensed libraries, etc. since they allow linking from closed source code, but we can't make changes to those libraries to support work projects for the same reason (if the license requires changes to the library itself to be open-source).
We're a relatively new org so our departments aren't yet "mature". We have a single legal consultant (who did this training) who is not an employee. One question that came up more than once was use of code on Stack Overflow. Stack Overflow states that code posted to the site is licensed under CC-BY-SA. The "SA" part is the problem, as it is generally interpreted to be similar to the GPL.
If I take a snippet of code from SO in unchanged format, I can state that I acquired it from SO and place a link to the post in the code (that covers the "BY" part). But CC-BY-SA doesn't make it clear if this now requires the entire code base to be licensed under CC-BY-SA, or just the part that I pasted.
It's even grayer if I use SO code but modify it to suit my purposes. In the broad sense, CC-BY-SA would then require me to release my changes (although I'm not sure exactly where I'd do that). However, if the changes made to the code involved anything proprietary, that of course presents a problem for the org. But even something as simple as changing a string in the code could be seen as a modification.
So far, our "consultant" has no solid advice because of the ambiguity of CC, but suggests "you might want to consider perhaps not using code from StackOverflow". (The consultant didn't even really seem to know much about SO itself, suggesting he's likely not a developer and focuses strictly on legal issues) As developers, we all of course heavily rely on SO even if for advice and guidance on how to perform some task in code. Amongst us devs, barring use of SO is enough to make some of us seek employment elsewhere because it is such a valuable resource. Of course, SO is not the only website that publishes sample code; even some books license their sample code under CC licenses.
To make things even more complicated, sometimes a snippet of code from SO is a single line of code. Sometimes this single line of code is the best or most efficient way to perform the task at hand in the language in question. Now that I've looked on SO and learned that technique, is using the code now considered CC-BY-SA?
Essentially, I can't imagine how you could develop code these days under these conditions. If you can't use any code you got from SO in a closed-source project, and if even learning how to do something from SO might require you to license your implementation under CC, basically we can never work for an organization that requires closed-source code! (This may seem to be a logical extreme, but then again, the legal consultant did basically tell us to always assume the worst case and steer clear of any ambiguities.)
Naturally, I'm not seeking actual legal advice, but am interested in how others have approached or addressed this situation. SO is so popular that I haven't yet met a modern developer who hasn't used it for advice. But closed-source software is alive and well all over the place. From a legal perspective, is it honestly the case that everyone writing closed-source code for a business cannot legally use code (or even reference code) from SO?