http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52539
--- Comment #20 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> --- Created attachment 32725 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32725&action=edit New preliminary patch - please test This patch takes a different approach. I have split up next_char and push_char into several smaller functions to eliminate testing for ENCODING and is_internal on every character read. I have added two function pointers to the the gfc_unit structure and these pointers are initialized at the beginning of the I/O statements once. I then use wrapper functions to invoke the function pointers. This approach keeps everything nicely separated, is cleaner, and should have better performance. I will probably replace the wrapper functions with simple macro expansions. However as it is attached it is good for some heavy testing by everyone. I have regression tested on x86_64 and the test in Comment #12 works now.