What does the Plumbing Code say about securing a bathtub faucet to the studs?
Take a look at item 2, from section P2705 of the 2006 International Residential Code.


  SECTION P2705 INSTALLATION 
  
  P2705.1 General. 
  
  The installation of fixtures shall conform to the following:
  
  
  Floor-outlet or floor-mounted fixtures shall be secured to the drainage connection and to the floor, where so designed, by screws,
  bolts, washers, nuts and similar fasteners of copper, brass or other
  corrosion-resistant material.
  Wall-hung fixtures shall be rigidly supported so that strain is not transmitted to the plumbing system.
  Where fixtures come in contact with walls and floors, the contact area shall be water tight.
  Plumbing fixtures shall be usable.
  The centerline of water closets or bidets shall not be less than 15 inches (381 mm) from adjacent walls or partitions or not less than
  15 inches (381 mm) from the centerline of a bidet to the outermost rim
  of an adjacent water closet. There shall be at least 21 inches (533
  mm) clearance in front of the water closet, bidet or lavatory to any
  wall, fixture or door.
  The location of piping, fixtures or equipment shall not interfere with the operation of windows or doors.
  In areas prone to flooding as established by Table R301.2(1), plumbing fixtures shall be located or installed in accordance with
  Section R324.1.5.
  Integral fixture-fitting mounting surfaces on manufactured plumbing fixtures or plumbing fixtures constructed on site, shall meet
  the design requirements of ASME A112.19.2 or ASME A112.19.3.