Not an evolutionary flaw, but a really cool concept called kin selection (in some species). The fact that the bees are closely related, and in some cases related by 75–100% (haploid drones come from unfertilized eggs), means that sacrificing one’s self does not result in forgoing the chance to pass your genes to the next generation. In fact, through this sort of altruistic behavior, the stinging bee helps ensure its genes do get passed down via related individuals. Another example would be something like wolves, where typically there is one breeding female and her sisters who don’t usually breed. By not breeding themselves, the sisters don’t get to pass their genetic material through the generations; however, since sisters share roughly 50% of their genetic material, they still get to pass some of their genes if the alpha female reproduces. The alternative would be leaving the pack and starting another, but the chances of success for that are quite slim, so it is worth it to remain in a pack with the guarantee of safety and food and only getting some of your genetic material into the next generation, as opposed to leaving with a small chance of reproducing yourself, yet with a slim chance of survival. I hope that makes some sense. Check out Hamilton’s theory of kin selection for more info. http://en.wikipedia.org/wiki/Kin_selection