Yes, with room to spare. My NIKON P510 fits into this bag with almost 2 inches of free space between the camera and the top of the bag, The 2 zippered compartments (1 on each side) provides ample storage for accessories. It's a good, sturdy bag. I'd recommend it!
It would fit, but it wouldn't be snug. I think that's the goal for these types of cases. You would have quite a bit of room, and not sure if you would want to put anything else in there. My 7D + 17-55mm was a decent fit, but anything smaller would make the camera juggle inside which defeats the purpose and wouldn't feel good for those hiking trips and such.
Great case, but if it were me honestly, I would get something that would fit the SX40 a little better.