How include css class based on post ( in loop ) slug?

The error you get is produced by $slug = get_post( $post )->post_name; because there is no post_name on a 404 page. So, to prevent this error you must structure the function in a way it doesn’t get to this line when it is called on a 404-page. Like this:

add_filter ('post_class', 'fl_pages_bodyclass');
add_filter ('body_class', 'fl_pages_bodyclass');
function fl_pages_bodyclass ($classes) { 
  global $post;
  if (!is_404()) {
    $slug = get_post($post)->post_name; 
    $classes[] = $slug;
    }
  return $classes;
  }