I was rather surprised that in this answer which suggests that a supervisor giving a side-hug to a research assistant is acceptable behaviour. I try and limit the physical contact with my students/postdocs/assistants to hand shakes and high fives, however if they initiate a hug I tend not to block it. What physical contact, if any, is acceptable between a supervisor and a student? I guess a follow up question would be do the genders of the supervisor or student matter?
In general, I refrain from initiating any physical contact other than handshakes or "congratulatory" gestures such as high-fives or fist bumps. This allows the student to control the level of interaction if they so choose.
My suspicion about what would be considered "acceptable" is that it varies widely from country to country, depending on what is considered an "acceptable" level of contact between strangers or professional colleagues. For instance, in Muslim-dominated countries, the "side-hug" mentioned in the answer—or even shaking of hands—between a male boss and a female subordinate, or vice versa, would likely be frowned upon! Similarly, in other countries, I could see how a "side-hug" could be within the realm of acceptable contacts (although still on the somewhat "iffy" side).
I'm glad you asked the question, since I was very struck by the answer as well: as I indicated in a comment, I am rather confident that the sentiment expressed there that hugs are always okay is against the policy of my university. As Tara B mentioned, any physical contact between coworkers that is not explicitly part of the work done needs to be clearly acceptable to both parties. There is no doubt that sometimes a hug is more contact than one wants. When I first arrived at my current job a certain SO of a colleague reacted to meeting me for the first time by giving me an aggressive hug while I was seated, so I could not easily regulate or terminate it. While certainly not "traumatic", in the long years since then, whenever I see this person I instinctively track them closely enough so as not to "get caught" as I did that one time. If it had been my colleague rather than my colleague's SO, it would have been worse.
As other people have said, what is an acceptable level of physical contact must vary culturally to a large degree. Here's what I've come up with in my years at an American university:
1) When in doubt, err on the side of restraining yourself from what you think will most likely be okay. Academics (okay, especially mathematicians) are not known for being the most touchy-feely people, and academic culture is more highly respective of personal boundaries than most other aspects of American culture, with the possible exception of certain religious groups. As an academic "lifer", I sometimes have to remind myself that people I meet in "real life" sometimes react negatively to a total lack of physical contact: in many situations it signals a lack of interest (and not only of romantic interest) and closeness. In academia it is really always acceptable to keep your hands to yourself. Always.
2) The academic hierarchy does have a role to play. I can't think of a situation in which I would ever initiate contact with an undergraduate student. If they offer to shake my hand, I do so. [For those outside American culture: not to shake someone's hand when they offer it is, from a core cultural perspective, amazingly rude. In recent years the mysophobe fist-pounding movement has gained some momentum, but I'll bet that it still very often happens that Howie Mandell offends someone by refusing to shake their hand. Actually the linked to article has interesting information about this: the things that Mandell does instead of shaking hands would be viewed by many academics as more intimate. Also, I can't resist mentioning that I just learned that Mandell is not actually bald but shaves his head for mysophobic reasons. Wow.] I would accept a hug from an undergraduate as a parting gesture: that's about it.
Graduate students are a little older, and I also have more prolonged contact with them (both in the sense of multiple hours at a time and multiple years in succession). This builds a little more intimacy. Like @StrongBad I regard certain climactic moments of academic accomplishment -- e.g. solving your thesis problem -- as worthy of a high-five. My thesis advisor patted me on the back as he told me that I passed my thesis defense.
The "don't touch" rule is still generally in force, but I can think of some exceptions. Once I had an emotionally intense conversation with a graduate student -- a conversation entirely about her performance in the program! During the course of this conversation the student showed me more of her own thoughts and feelings (about being a graduate student...) in that one sitting than in all the time I had known her. It is not so easy to open up to an authority figure about these things, and I felt that as a human being I needed to let her know that she had gotten through to me, so I asked her if I could give her a hug, and I did.
[In fact I got the idea from an emergency room physician who had given me a hug about six months before. She acknowledged that the hug was unusual but thought that I really needed it (she was right) and asked for permission to give it.]
I still feel that 99% of the time "no touching" is the right way to go, and if you think you might be in the 1%, take a step outside yourself and make sure that someone else would see it that way. For instance it is unfortunately not unheard of that a student breaks into tears in my office [it happens every year or two; come to think of it, I am more than due for such an incident]. My standard reaction to this is to dash out to get some paper towels / tissues [and give themselves a chance to get recomposed] and come back and helpfully offer them. Hugging them because calculus is hard seems like participating in a weird power dynamic. If a student got a text that their mother died, I might offer a hug.
Postdoctoral "students" feel a little different: I am still young enough (and young enough at heart) to identify more with the postdocs than the 20-year veteran faculty members. I certainly don't hesitate to socialize with postdocs: they have been some of my closest friends in the department. But for postdocs who are working under me I want to set clear boundaries: if I've been working with someone closely for hours a day, then an occasional arm or shoulder touch to emphasize a point feels natural enough...but I would still think about it, watch the reaction, and not automatically assume it's okay. Hugging it out is still not the order of the day.
3) You ask whether genders matter. I think the answer is that of course they do, in complicated ways. I am conscious of the fact that while writing this answer I spent a while thinking over all the physical contact, however mild, I've had in a professional capacity...and almost every instance I could think of was with someone of the opposite gender. Hmm! In general I have an open-door policy in my office hours: literally. Even when talking to a single student about their own coursework I would like the door to be open, even at the cost of passersby hearing some moderately confidential academic information. If there is noise coming from the hall I might close the door....but I will absolutely never close the door fully (which makes it lock) when I am accompanied by exactly one female student. (With a male student I would still prefer not to, but I might say "It's very noisy outside. Would it be okay if I closed the door because of that?" With a female student: it is not okay.)
In American culture physical contact between men is countenanced in certain very specific situations [I'm think of certain locker room antics] and is quite taboo in many others. I do hug male friends but less often: it is usually a profound gesture of intimacy. [Many years ago as a graduate student, I was at a conference and shared a room with another student. At the end of a couple of weeks he gave me a hug as we parted. Well, he was Japanese, I was American and we were in Spain: my cultural rulebook does not cover that situation, so I went with it.] Also, once I had a male student start crying in my office (about his performance in a calculus course). This was a profoundly distressing event for both of us, beyond my ability to understand or explain, and the point is that I felt utterly unequipped to do anything about it, least of all by physically comforting him: it seems very likely that would have made things worse.
Some of this may depend on the age of the students, the relevant law of the country, and policies of the institution. I'm replying from a USA-centric, adult, and parent viewpoint.
I am a USA Swimming certified official. Part of the required training is on their 'Athlete Protection Policy', dealing with allowable interactions between adults (coaches, officials, team representatives) and swimmers (age group or over 18). Shaking hands and fist bumps like @asismail list are acceptable. Hugs initiated by the adults are not. Hugs initiated by the swimmer are also not really OK - they might happen once in the heat of the moment (winning Olympic gold), but should not be repeated. This ensures there are clear boundaries between the adults and the swimmers (any age). There should be no doubt to a neutral observer that there is nothing going on. If this sounds too 'politically correct' to you, tough. Sexual harassment and sexual abuse happen, and USA Swimming wants nothing to do with it. Likely your institution has no desire for it to occur either, and has policies in place about it. If the student feels uncomfortable, don't do it. If somebody watching you is uncomfortable, don't do it.
As a manager of a research group, I have positional authority over my adult staff, and all the same issues apply. You don't want anyone thinking that anything untoward is going on. I would never hug a subordinate, male or female, and would not let them hug me under any normal work situations (I'll omit extreme cases such as us all getting out of a burning exploding building). It opens up too many questions. Even a side hug seems unusual. Lightly and briefly touching a shoulder is OK, unless they seem uneasy. I don't do it often. Perhaps that seems cold, but my observation is that even 'touchy-feely' folks don't really do much touching in a professional workplace environment. In an environment with students I'd stick to no actions that could be interpreted as remotely sexual by a third party observer.
The things I want to say on this topic should possibly be comments really, since I think the only 'answer' is that it varies hugely between different cultures (as aeismail already said).
Personally, like aeismail, I would not initiate physical contact with students, or indeed with colleagues (I'm still a postdoc myself). This is probably a good policy to follow, especially with something like hugging, unless hugs are not only generally acceptable but even expected in the local culture. The exception might be if a student has finished their studies and is leaving the university. I think I may have given my final-year project student a goodbye hug.
This extends, in a sense, to students who I happen to be friends with outside work (there are a few of these, since I belong to a student dance society). Even if I might hug someone frequently in a non-work context, I wouldn't hug them when we are in a teacher/student context. On the other hand, if it would be normal to hug someone in the friendship context, I wouldn't refrain from doing so just because they are also my student.
EDIT: As for the question about whether gender makes a difference: again this may be culturally dependant, but in the countries I have studied or worked in (the UK, Germany, New Zealand), any supervisor-student physical contact would be much more likely where at least one of the people involved is female, due to similar cultural expectations about physical contact between males to those mentioned by Pete Clark in his answer (though my impression is that this may be more extreme in (certain parts of?) the US than in the UK). And high levels of discomfort are probably unlikely where both of the people involved are female, while more caution would be expected with opposite genders. (This of course arises partly from these cultures being highly hetero-normative.)
If it is a climax moment (when the research question is clearly answered, earning a scholarship, graduation, etc.), it is absolutely normal to have an additional physical contact beyond a handshake. We are humans and when emotions accelerate, the need of communication goes beyond verbal. The first time I saw my supervisor after we both read some good news about my thesis, we both held each others' arms at the same time,it was such a synchronized moment which mirrored our intellectual harmony.
If both parties are adults, what is acceptable is whatever the two parties feel is acceptable in a workplace. There are laws that tell you exactly what is not acceptable. I fail to see how a side hug would be harmful, unless it was forced (directly or indirectly). I don't think it's anyone's business to decide what is acceptable or not between two intelligent adults, within the confines of the law and general etiquette of course.
In an ideal world any amount that would be permissable between friends would be fine.
Of course, I dont work in academia, but IMHO, since everyone is adults, I think you could intiate a hug.
From a risk minimizing perspective, it would be unwise, but if you live your life based on those kinds of risks, life gets boring.
I also think the current moral panaick is showing signs of subsiding, I think people are slowly swingingback to a presumption of innocence and considering evidence of every case, not looking thourgh a macronarraitve that presumes either the accuser is right (now) or the accusser is always wrong (ten years ago).
Its tricky though, I dont think the problem of true and false accusations will ever stop until people are allowed to precommit themselves to a neutral third party arbiter that can investiagate claims credibly.
If you are a man, I would avoid all unnecessary physical contact, any unnecessary 1-on-1 meetings behind closed doors, and all unnecessary socializing. Does this sound absurd? Maybe. I recently read a good article on a similar issue focused on the workplace, but the idea applies in academia as well:
You can't know what will offend your students, and they could make an allegation ten years down the road that might cost you your job, even if the allegation is 100% fictional. Leave no room for doubt! Assuming you are male, I would avoid taking on female students entirely when possible. This is unfortunate, but is it worth risking your career?