from World Chelonian Trust article on star torts:
HOUSING STAR TORTOISES INDOORS - A reasonable size for a hatchling is 2 feet by 2 feet, (60 cm by 60 cm). As the animal grows the size of this habitat should be increased. For an adult Star tortoise the indoor habitat should be at least 4 feet by 4 feet, (120 cm by 120 cm).
Rest of article here: 66.201.110.205/Articles/Geleganscare.htm
I don't know the dimensions of a 40L, but the 40-gallon tanks I've seen are about 3'x1.5', or barely large enough for a single hatchling. In fact, there are no readily available tortoises or box turtles that should be placed in a 40-gallon tank for their entire lives.
In my opinion, a 4"-8" tortoise/land turtle should be given at least 8-16 sq ft. I give my russians about 4 sq ft of space *each* for a few weeks before and after hibernation. During that time they are dull and sluggish - partly because they are slowing down or recovering from hibernation - but also because a tortoise stuffed into a small space just gives in and doesn't move much. Either that or it struggles against the cramped quarters.
For the rest of the year, my 3 adult russians share a 64 sq ft pen, and my juvenile has an 18 sq ft pen to himself. They come to life with this much space, and spend time grazing, sunning, chasing each other, laying eggs, etc.
I have 3 three-toed box turtles that share a 13 sq ft space outdoors, but they are temporary adoptees waiting for a better home. This is not an optimal setup for them.
So unless you have a lot of space to devote to a tortoise, I would recommend you don't get a star. An Egyptian tortoise might be able to survive in 4-6 sq ft of space, but from what I've heard they are not cheap and not easy to keep.