Ticket #3332 (closed bug: invalid)

Opened 4 years ago

Last modified 4 years ago

take n (take m list) returns [] for some m.

Reported by: fcamel Owned by:
Priority: normal Milestone:
Component: Compiler Version: 6.8.2
Keywords: Cc:
Operating System: Linux Architecture: x86
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

See the example below. I think the second output should be [1], too. I also tried ghc and runghc, and the results were the same.

ghci> take 1 (take (10^11) [1..])
[1]
it :: [Integer]
ghci> take 1 (take (10^12) [1..])
[]
it :: [Integer]
ghci> take 1 (take (10^13) [1..])
[1]
it :: [Integer]

Change History

Changed 4 years ago by igloo

  • status changed from new to closed
  • difficulty set to Unknown
  • resolution set to invalid

Thanks for the report. But actually, this is not a bug:

On a 32bit machine, (10^12) :: Int is -727379968.

This will give you [1]:

import Data.List

take 1 (genericTake (10^12) [1..])
Note: See TracTickets for help on using tickets.