public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/33000]  New: cin fails to allow input to be entered
@ 2007-08-06  4:45 vanemden at cs dot uvic dot ca
  2007-08-06  4:57 ` [Bug libstdc++/33000] cin and hex input (==8 digits gets rejected) pinskia at gcc dot gnu dot org
  2007-08-06  4:59 ` pinskia at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: vanemden at cs dot uvic dot ca @ 2007-08-06  4:45 UTC (permalink / raw)
  To: gcc-bugs

linuxthing$g++ -v
Reading specs from /usr/lib/gcc/x86_64-redhat-linux/3.4.6/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-java-awt=gtk --host=x86_64-redhat-linux
Thread model: posix
gcc version 3.4.6 20060404 (Red Hat 3.4.6-3)
more main.c
#include <iostream>
using namespace std;

int main() {
  cout
  << "Input in hex two integers x and y." << endl;
  int x, y; cin >> hex >> x >> y;
}
linuxthing$more makefile
run: prog
        ./prog

prog: main.o
        g++ -o prog main.o
#       gcc -o prog main.o -lm
# -lm option to ensure sqrt gets included from math lib

main.o: main.c
        g++ -c -Wall main.c
#       gcc -c -ansi -pedantic -Wall main.c
#       gcc -c -Wall main.c

clean:
        rm -f main.o
        rm -f prog
linuxthing$make run
./prog
Input in hex two integers x and y.
aaaaaaaa
linuxthing$
-----------------
This shows the failure to allow input.
Below follows the intended behaviour as given by an earlier version of g++
-----------------
yang$g++ -v
Reading specs from
/package/gcc-2.95.2/lib/gcc-lib/sparc-sun-solaris2.8/2.95.2/specs
gcc version 2.95.2 19991024 (release)
yang$more main.c
#include <iostream>
using namespace std;

int main() {
  cout
  << "Input in hex two integers x and y." << endl;
  int x, y; cin >> hex >> x >> y;
}
yang$
run: prog
      ./prog

prog: main.o
      g++ -o prog main.o
#     gcc -o prog main.o -lm
# -lm option to ensure sqrt gets included from math lib

main.o: main.c
      g++ -c -Wall main.c
#     gcc -c -ansi -pedantic -Wall main.c
#     gcc -c -Wall main.c

clean:
      rm -f main.o
      rm -f prog
yang$make run
g++ -c -Wall main.c
g++ -o prog main.o
./prog
Input in hex two integers x and y.
aaaaaaaa
bbbbbbbb
yang$


-- 
           Summary: cin fails to allow input to be entered
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: vanemden at cs dot uvic dot ca
 GCC build triplet: gcc version 3.4.6 20060404 (Red Hat 3.4.6-3)
  GCC host triplet: linux.cs.uvic.ca
GCC target triplet: linux.cs.uvic.ca


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33000


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libstdc++/33000] cin and hex input (==8 digits gets rejected)
  2007-08-06  4:45 [Bug c++/33000] New: cin fails to allow input to be entered vanemden at cs dot uvic dot ca
@ 2007-08-06  4:57 ` pinskia at gcc dot gnu dot org
  2007-08-06  4:59 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-08-06  4:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2007-08-06 04:56 -------
If I add a check for errors:

#include <iostream>
using namespace std;

int main() {
 cout
 << "Input in hex two integers x and y." << endl;
 int x, y;
  if(!cin)
   cout << "error" << endl;
  cin >> hex >> x >> y;
  if(!cin)
   cout << "error" << endl;
  else
    cout << "y: " << y << "x: " << x << endl;
}


----
Then I get this behavior:
Input in hex two integers x and y.
aaaaaaaa
error

If I enter less than 8 digits, it gets accepted.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c++                         |libstdc++
  GCC build triplet|gcc version 3.4.6 20060404  |
                   |(Red Hat 3.4.6-3)           |
   GCC host triplet|linux.cs.uvic.ca            |
 GCC target triplet|linux.cs.uvic.ca            |
            Summary|cin fails to allow input to |cin and hex input (==8
                   |be entered                  |digits gets rejected)
            Version|unknown                     |3.4.6


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33000


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libstdc++/33000] cin and hex input (==8 digits gets rejected)
  2007-08-06  4:45 [Bug c++/33000] New: cin fails to allow input to be entered vanemden at cs dot uvic dot ca
  2007-08-06  4:57 ` [Bug libstdc++/33000] cin and hex input (==8 digits gets rejected) pinskia at gcc dot gnu dot org
@ 2007-08-06  4:59 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-08-06  4:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2007-08-06 04:59 -------
No this is expected behavior as 0xaaaaaaaa < 0x7FFFFFFF for signed integers so
there is an error that is expected.  


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33000


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-08-06  4:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-06  4:45 [Bug c++/33000] New: cin fails to allow input to be entered vanemden at cs dot uvic dot ca
2007-08-06  4:57 ` [Bug libstdc++/33000] cin and hex input (==8 digits gets rejected) pinskia at gcc dot gnu dot org
2007-08-06  4:59 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).