On the inner tube it is written: 700X28/32C.
If that's the specification of the inner tube, it either has to be a particularly bad inner tube or dishonest marking on it.
Schwalbe sells 28-47mm tubes.
Continental sells 32-47mm tubes and I have observed them to work with 28mm tires, but they require maybe 10-15 seconds of extra carefulness when installing them if using with 28mm tires. Not an issue.
So either the low end of the range (stated: 28mm) could accommodate narrower tires, or the high end of the range (stated: 32mm) could accommodate wider tires. Or maybe the butyl rubber used in the tube is particularly bad.
If the high end of the range accommodates wider tires, you probably can use it with 40mm tires. But if the low end of the range is the one that's mislabeled, and it could actually even work with 23mm tires, then maybe you're asking too much from the tube by using it with 40mm tires.
The only way to know for certain is to buy some tubes with honest labeling and compare their width.
Nevertheless, my heavy recommendation is to always use the widest possible tube you can fit in. So this means if you have 40mm tires, my recommendation could be for example Schwalbe AV 19 which is for 40-62mm tires. The reason being is that the less the tube has to stretch, the thicker the walls are in the stretched state, which reduces the rate of air loss through the tube walls.
Also, the other answer stated that the behavior in case of puncture is far different on a tube that has stretched a lot as opposed to a tube that doesn't have to stretch at all. This also reinforces my advice of always using the widest tube that's possible to fit in.
Maybe the tube is the same as Schwalbe 28-47mm, but the manufacturer is aware of the bad effects of letting the tube stretch too much, and label it as 28-32mm instead?