How to Bend profiled rectangle exactly to 45 degrees?
This is rather easy to do.

Just add a Simple Deform Modifier.
Set it to Bend and select the right axis.
Enter the desired angle (it's 45° by default)



Note:
In this case bending along the Z axis doesn't work as expected.
To make it work, rotate the object's origin by -90°, or use an empty rotated by -90°.



Thanks to @lemon, @plem and @robin-betts for pointing that out.