"file_in.getline", compiler error?

This is a discussion on "file_in.getline", compiler error? within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by cyberfish I just tried it with gcc 4.1 some time ago. It only gets optimized on -O3, ...

  1. #16
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,420
    Quote Originally Posted by cyberfish View Post
    I just tried it with gcc 4.1 some time ago.

    It only gets optimized on -O3, not even -O2.
    I was unable to get it optimized away at all. I'm thinking the compiler doesn't know anything about strlen and thus cannot assume that it will return the same thing everytime you call it.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #17
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,167
    I was unable to get it optimized away at all. I'm thinking the compiler doesn't know anything about strlen and thus cannot assume that it will return the same thing everytime you call it.
    It only gets optimized away on the highest optimization level on gcc. I am guessing perhaps it's because strlen is inlined in -O3 (-O3 turns on heuristic function inlining). I have never examined the asm output, however.

  3. #18
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,420
    Same for Visual Studio. The function was inlined, but not optimized away. I guess gcc was the better optimizer.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do you resolve this error?
    By -EquinoX- in forum C Programming
    Replies: 32
    Last Post: 11-05-2008, 03:35 PM
  2. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  3. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  4. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 09:43 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21