Someone pointed out that it may be risky, and it might not have the right kind of nozzle, but I don't have a bike pump at the moment. Does anyone else ever do this?
The answer, in short is: Can you? In some cases, yes. Should you? In most cases, no.
The long answer: The reason you can sometimes use an automotive air-pump on a bicycle tire/tube is because they share an identical valve. (See: Schrader valve/Schrader tube in the Terminology Index). If you have this type, you will definitely be able to get air into your tubes in a pinch. However, air hoses from gas stations are usually unregulated, high-pressure & high-volume, and lack a pressure gauge. Therefore, it is much easier to over-inflate and even blow out your bicycle tire, if you were to use one.
An investment in a bicycle pump is one of the best you can make as a cyclist. Not only will it get you out of situations like this, but it will make it easier to keep your tires at the recommended pressure rating, which in turn will make it easier for you to be a more efficient (read: faster) bicyclist.
You can do this in a pinch if you're careful, but I don't recommend it. Your tires need to have Schraeder valves (similar to car tires) or you'll need an adapter for a Presta valve. Fill the tire in very short bursts, checking the pressure in between. Err on the side of underfilling your tires -- put too much air in and you may blow the tire off the rim, which is worse than having a flat in the first place!
I used to do this 20 years ago before I realized that there were small pumps you can take with you. In addition to the risks, the problem with gas station pumps is that they're never there when you need them. The one repair kit you should have with you at all times is a pump + patch kit (or spare tube). Trust me, it can be a long, long walk home without them!
I would say it depends - here in the UK the air pumps at petrol stations all have pressure gauges of some sort, but many aren't suitable. The digital ones where you select the pressure to which you want your tyre inflated often max out at 60psi* but that's not the problem - the problem is that they inflate for a bit then let a bit out to test and correct. And they assume a car tyre. So to get a car tyre from say 30psi to 34, they might hit 46 and then let some out. To get a bike tyre from say 55psi to 60 they will put enough air in to make a car tyre inflate by a few psi - meaning your bike tyre will get rather too hard. I don't fancy measuring the peak pressure they'll do. That's why they say not to use them for bikes.
The older sort with a proper pressure gauge also generally have a trigger that you can press lightly, and should be OK.
I'm assuming you're sorted for valve compatibility here.
*not even high enough for my van, resulting in some hard work with my track pump to finish the job.
It is possible, but there are a few factors to consider:
Valve Type, obviously it is easiest with a schraeder valve, as these are the type that cars use. You can get adapters for presta valves that screw on and allow you to use the service station pumps.
Tyre Volume, as noted in some other answers, the air supply at service stations is often unregulated. The smaller your tyre, the faster the pressure increases - so you run more risk of over-inflation for narrow road tyres than for large mountain bike tyres.
Pressure, road bike tyres are generally inflated to 110 - 130 PSI, which is much higher than the 30-40 PSI used for car tyres, or the 30-60 PSI used for mountain bike tyres. The service station pump may not be able to achieve this pressure, particularly if it is one of those automatic inflation types.
So, in short, if you've got a mountain bike, there is probably not much of an issue using the service station pump. If you've got a road bike, do yourself a favour and buy a decent track pump. That way you'll be able to top up the tyres quickly each time you go out, and enjoy the benefits of nicely inflated tyres.
Can you use gas station air pumps on a bike : Most likely especially for mountain bikes and BMX bikes (unless your tubes use a different valve type), Is it a good idea : Probably not, unless your very careful and have no other way to pump up a tire.
I've never had much of an issue using gas station air pumps with mountain bikes and BMX bikes, as most bike tyres I've seen use Pressures from 40-50 PSI, but I rarely go to the max to prevent a blow out which I've done a few times pushing the pressure to the max.
Most gas stations in Canada have pumps which have a built in pressure gauge on the handle, which works a lot like a tire pressure checker. Its probably not as accurate as other means but this is another reason why I wouldn't risk pumping a bike tire to max pressure.
Either way, since I'm a poor person who usually forgets to get things like tools and pumps when they have money, this is usually my only way of pumping up a bike tire when I don't have a pump at home. Though its so much better when you do have one at home so you don't have issues like having a soft/flat tire before you head out for work on bike or just want to run down to the store to get something.
I use the air pump at gas stations all the time for years with no issue. The pumps with the air pressure gauge on the handle are best. One caveat, I never fill it to the recommended top of the scale psi, I always use about stop about 10 psi from full.
If you are using a gas station pump then you are out and about, have a flat tire or very little air in your tires or have a puncture, either way you need air for your tires and in this scenario it is perfectly fine to use the gas station air pump once you are careful. You can use a linen handkerchief or any piece of cloth to put between the air pumps nozzle and the tire nozzle to offset the burst of air from the pump if you are concerned but it is not really needed. Just be careful and underfill rather than overfill. If it's the type of pump that has a pressure gauge on the handle that is ideal, if it's the preset one just set the pressure lower before use.