G++ compiler strange behavior