Many people are wondering whether aluminum foil
is toxic or not when heated. The answer is no, because aluminum foil has a "skin" of inert aluminum oxide. This layer is harmless and presents no danger. But acidic foods can and do leach aluminum ions into the food. Once popular aluminum cookware was lauded for heat conductivity and ease of cleaning but if you used those pots for making tomato sauce for example, you were also getting a dose of aluminum.
It's not all that toxic so once in a while is not really going to harm you. Cast iron does the same but iron is integral to our cellular metabolism and conveyance of oxygen.
Bottom line is try to keep acidic foods from coming in contact with aluminum. If you are tenting a pot of tomato sauce or sauerkraut, no harm, just don't cook those foods in contact with aluminum.
Heat really has nothing to do with it. Just storing acidic foods in aluminum is not recommended. Heat will increase the reaction, of course but it happens anyway. Even in the fridge.
So, to reiterate cooking with foil is ok depending on the food. Wrapping potatoes or corn and tossing on the grill is fine. Those foods are starchy and contain sugar. Same goes for hot dogs and meats. Acidic foods change the game.