Brockett's necessary condition yields a test to determine whether a system can be made to stabilize about some operating point via continuous, purely state-dependent feedback. For many real-world systems, however, one wants to stabilize sets which are more general than a single point. One also wants to control such systems to operate safely by making obstacles and other "dangerous" sets repelling. We generalize Brockett's necessary condition to the case of stabilizing general compact subsets having a nonzero Euler characteristic. Using this generalization, we also formulate a necessary condition for the existence of "safe" control laws. We illustrate the theory in concrete examples and for some general classes of systems including a broad class of nonholonomically constrained Lagrangian systems. We also show that, for the special case of stabilizing a point, the specialization of our general stabilizability test is stronger than Brockett's.