Context makes a massive difference. As I've said before, some comedians are very good at letting the audience understand that they themselves don't agree with the implied (or sometimes stated) attitudes present in the joke. Those attitudes are themselves the subject that is ridiculed.
I've been trying to think of examples but whenever I start writing a really nasty joke that would illustrate it I find myself wondering if it really is necessary to cross the line just to make a point. If we were at a stand up gig and I had already done some jokes that clearly poke fun at stupid attitudes you could hear my heavier jokes as essentially the same; but if I just blurted out, with no context, a really disgusting and possibly bigoted joke you might very well conclude that I do agree with the attitudes behind the apparent subject of the joke.
That really is the challenge - making your audience understand that everything you say is meant to be a joke, and that they're not supposed to adopt any attitudes from your jokes.
So if I told you that a wedding dress is white because that's the colour that home appliances such as ovens and dishwashers normally are, it looks like I'm saying that a wife is to be considered a home appliance; but the context of the joke should be such that you'd understand that I'm actually ridiculing the idea
that some people essentially consider women as household appliances.
So the real
subject of that joke is sexism, and the outdated social norm that women should take care of the home in the way that home appliances do. In my joke1
to believe the notion that women are essentially utilities, but the message I'm trying to convey is that it is absurd to think like that, as equating people to machines, especially in the context of something that is generally considered very positive, is something that we should ridicule.
Of course there is the risk of someone in the audience hearing the joke as endorsing
their pre-existing idea that women are essentially utilities; but that, again, is something that can be remedied by context. If the jokes surrounding this one are also based on the format that what you mean is roughly the opposite of what you say, even a stupid listener should eventually notice that the idea they thought you were endorsing with your joke was actually being ridiculed, and that most of the other people in the audience got this and were, without knowing, laughing at you
if you held those kind of bigoted ideas.
I like jokes like the one above very much, because I think they can be very clever (much more so than the one above) and because I think they are a good way to approach difficult subjects and to notice absurdities in your attitudes; but it is very hard to tell those jokes right, as your audience basically has to know you well enough to see through them. That, again, comes back to context. In the context of a Jimmy Carr gig you know
(or should know) that this is what is going on; but during a coffee break at a workplace it might be that your audience doesn't really know you well enough to know what the joke was supposed to mean. If you tell such jokes to the people who are the apparent
subject of the joke it can be a form of bullying if you fail to let them know that you're really on their side.
Well, I'm basically repeating everything I've said before but at least this time I managed to include an example. Oh, and the footnote...
The narrative in that example was that I was telling that joke to you, which is why I called it "my joke" as a shorthand for "the joke I am telling to you". I would like to point out that I didn't actually come up with that joke, though, and I want to make sure I'm not stealing anyone's joke by claiming it as mine when it's not.
Quod gratis asseritur, gratis negatur.