Oh good. A 'Good', 'Bad' and 'Don't Care' question.
The 'Good' up front.
Interchangeable ammunition. Only one set of loading dies. Same components to buy.
The 'Bad' is next.
Colt tried this marking approach way back... The Colt Lighting rifle and pistol. Great idea that didn't work out. You end up with a wimp rifle or a major hand full pistol. No one is happy.
But for our exercise. Both the .40 and the .45 are loaded for retarded blow back actions with set energy parameters and these must be adhered to. The normal barrel lengths are 4 to 5 inches and most ammunition is tailored to this length.
Now to the 'Don't care' section.
Hopefully you reload, if not think hard about it.
I load both the .40 and .45 with the same 231/HP38 powder... Same burn rate. Any [relatively] fast burn rate powder will be at a greater disadvantage with a long/er barrel when compared to any powder with a slower burn rate. At the same time, the comparability between the shorter pistol barrel and the longer rifle barrel must, if you still want to use the same ammo, be within the proper parameters to function.
What to do? Simple, load for your primary weapon and expect the other to suffer. How much will vary with loadings.
I don't have a rifle chambered in .40 S&W, so I can offer no help here. I do have a Marlin CampGun in .45 ACP.
The loading: 200 Grain LSWC, 5.6 grains of 231/HP38, CCI LP primers and mixed brass.
From a 5 inch 1911A1 barrel - 875 FPS (give or take).
From a 16 1/2 inch Marlin barrel - 1045 FPS (give or take).
My opinions and these have very little validity if any.
A shoulder arm gives a more stable sighting platform. In this case it is for a poor rifle round. My Marlin CampGun is NOT for sale.
A better combination would be a pistol/rifle combo in .357 Mag or .44 Mag or .45 Colt or.... Any case/round that normally can utilize larger quantities of slower burn rate powders will have much better potentials with the longer barrels, yet still be usable if not heavy loads in the pistol. And the proper powder will still need to be selected. I have a very good loading of 231/HP38 that pushes a 240 grain 44 at 1016 FPS and almost a duplicate loading using 2400 powder with the same bullet to the same velocity. Both of these are from the same 'pistol'. If fired from a longer barrel, the 2400 would excel and the 231/HP38 dribble off.
Standard disclaimer on my .45 ACP loading, it works with my components, in my weapons, but may not be safe in yours with your components. I use it as an example not as loading advise.
Load with care,