Sponsored Content
Full Discussion: is this a bug of g++?
Top Forums Programming is this a bug of g++? Post 302503601 by homeboy on Friday 11th of March 2011 04:24:42 AM
Old 03-11-2011
is this a bug of g++?

Hello,
Im using the g++(g++ Ubuntu/Linaro 4.4.4-14ubuntu5 4.4.5) and im trying to compile a small snippet code and got into an endless loop.I recompiled that in VS2010 under Windows 7 and the answer is as expected.so i wonder is this a bug of g++?here is my code.
Code:
#include<iostream>

using namespace std;

int main()
{
	int val;

	while(cin>>val,!(cin.eof())){
		if(cin.fail()){
			cerr<<"bad data,try again"<<endl;;
			cin.clear();
			continue;
		}else if(cin.good()){
			cerr<<"you entered :"<<val<<endl;
			break;
		}
}
}

---------- Post updated at 04:24 AM ---------- Previous update was at 04:07 AM ----------

Actually,the code::blocks with Mingw runs the code below OK while my g++ gets a endless loop.
Code:
#include <iostream>
using namespace std;

int main()
{
	int val;

	while(cin>>val,!cin.eof()){
		if(cin.fail()){
			cerr<<"failed,try again"<<endl;
			cin.clear();
			cin.sync();      //ADD THIS
		}else if(cin.good()){
			cout<<"you entered: "<<val<<endl;
			break;
		}
	}
}


Last edited by homeboy; 03-11-2011 at 06:11 AM..
 

8 More Discussions You Might Find Interesting

1. Programming

Bug has developed

Guys there is another bug that has developed.........now messaged above 6 bytes are trimmed and echoed back to client.After the first message the echo is not regular.I have put a loop in both client and server to check for closing.Moreover for connection close i also need to put another clause that... (3 Replies)
Discussion started by: arjunjag
3 Replies

2. Post Here to Contact Site Administrators and Moderators

Have I found a bug?

When searching for new posts, I see that my voting in one of the polls counts as a 'new post'. However, while the '<blah> minutes ago' entry updates correctly, the 'by <username>' is the last user to actually post a comment in the poll instead. Result: Poll: vB Guest Book 39... (4 Replies)
Discussion started by: Smiling Dragon
4 Replies

3. UNIX for Advanced & Expert Users

logrotate bug?

I have been mailing myself logs for a while, but just ran into a problem because of a process that cannot HUP its log. (I realize thats why they implemented the "copytruncate" option in the first place) When I use logrotate with "copytruncate" and "compress" there is a problem. The "myScript"... (0 Replies)
Discussion started by: jjinno
0 Replies

4. Shell Programming and Scripting

Is it a bug ..?

Hi All, I am using Red Hat Linux on my servers. The problem that I am facing is, sometimes the /opt usage on the server shows used percentage as 100% , when actually it is simply 20%. When I reboot the system, it comes back to 20%.Is this a bug in the system or my settings have gone wrong... (1 Reply)
Discussion started by: nua7
1 Replies

5. AIX

bug in 43 ???

xxxxserver# lsattr -El inet0 | grep 255.240.0.0,32.224.0.0,32.78.120.254 | grep '.40' route net,-hopcount,1,-netmask,255.240.0.0,32.224.0.0,32.78.120.254 How this is possible? (1 Reply)
Discussion started by: itik
1 Replies

6. UNIX for Dummies Questions & Answers

where's the bug?

#!/bin/bash if then #echo "infinite loop" exit 0 fi when I run this file I get the following error: ./test_infinite_loop: line 5: syntax error near unexpected token `fi' ./test_infinite_loop: line 5: `fi' :confused: (4 Replies)
Discussion started by: jon80
4 Replies

7. Shell Programming and Scripting

How to fix this bug?

Hi gurus, I have script as below: #!/bin/ksh while : do cat /dev/null > srcfile exit_time=`TZ=GMT-20 date +%Y%m%d1950` cur_time=`date +%Y%m%d%H%M` flag=1 if ; then ... (7 Replies)
Discussion started by: ken6503
7 Replies

8. UNIX for Advanced & Expert Users

A $(( expression )) bug?

This is for the big guns... I have been modifying AudioScope.sh to bring it inline with more current practices. I hit a bug which IS not present in the original code but was after modification. Shell check first:- #!/bin/sh txt="1234567890" echo "$(( $txt ))" echo "$(( ${#txt} - 1 ))" echo... (17 Replies)
Discussion started by: wisecracker
17 Replies
UCIMF(1)						      General Commands Manual							  UCIMF(1)

NAME
ucimf - unicode console input method framework DESCRIPTION
ucimf is an input method framework designed for Linux unicode console. FEATURE
o Support UTF-8 o Support OpenVanilla Modules o Support PCF, TrueType Font o Provide OverSpot style compose window o Provide C/C++ API BOOT PARAMETERS
Framebuffer mode is needed. You can add "vga=XXX" to LILO, GRUB, or other bootloaders to let the kernel start with proper framebuffer mode automatically. vga=785 (640x480, 16 ), vga=788 (800x600, 16 ), vga=791 (1024x768, 16 ), vga=794 (1280x1024, 16 ) USAGE
ucimf needs to run under an UTF-8 consle environment, please use locale -a to see the UTF-8 locales that your system is supported and use command like export LC_ALL=zh_CN.UTF-8 to set up the locale. To start ucimf with FbTerm, prefer to install fbterm-ucimf package and run fbterm -i fbterm_ucimf, or see ucimf_start(1) as an not-recom- mended alternate. When the user is running an FbTerm, key combination Ctrl+Space is the switch of enable/disable the input method, Ctrl+ShiftLeft to switch to next input method, and Ctrl+ShiftRight to switch to next input method framework. For jfbterm, F12 is the switch of enable/disable the input method, F11 to switch to next input method, and F10 to next input method frame- work. If the user wishes to use Ctrl+Space and Ctrl+ShiftLeft under jfbterm, please use ucimf_keyboard, which maps Ctrl+Space to F12, and Ctrl+ShiftLeft to F11. TABLE MANAGEMENT
ucimf use standard *.cin files directly to manage its input method tables, per-user input method tables is put in ~/.openvanilla/OVIMGeneric/. Installing or removing a table is simply copy or remove a file in that directory. The order of loading table is managed by the name of the table files, for exaple you can name your tables like this: 01_xxx.cin, 02_xyz.cin, 03_aaa.cin, ... ucimf will follow this order while loading input method tables. SHELL ENVIRONMENT
LC_CTYPE - use UTF-8 as to recogize characters. For example: export LC_CTYPE=zh_CN.UTF-8 OVMODULE_DIR - to customize OpenVanilla modules location at run-time. For example: export OVMODULE_DIR=/usr/lib/openvanilla/ SEE ALSO
ucimf_start(1), ucimf_keyboard(1), ucimf.conf(5). AUTHOR
libucimf was written by Chun-Yu Lee (Mat) <MatLinuxer2@gmail.com> and Jim Huang <jserv.tw@gmail.com>. This manual page was written by Aron Xu <happyaron.xu@gmail.com>, for the Debian project (and may be used by others). January 29, 2010 UCIMF(1)
All times are GMT -4. The time now is 01:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy